Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

1035287 views
1
//
2
// randomize_complex.cpp
3
// Bistellar
4
//
5
// Created by Alexander Thumm on 19.10.11.
6
// Copyright 2011 -. All rights reserved.
7
//
8
9
#include "randomize_complex.h"
10
11
#include <stdlib.h>
12
#include <time.h>
13
14
void randomize_complex(MovableComplex & complex, const std::vector< unsigned int > & allowedMoves, unsigned int rounds)
15
{
16
// initialize the RNG
17
srand(static_cast<unsigned int>(time(0)));
18
19
for (int currentRound = 0; currentRound < rounds; currentRound++)
20
{
21
int numberOfCodimensions = 0;
22
for (int i = 0; i < allowedMoves.size(); i++)
23
{
24
if (complex.hasValidMoves(allowedMoves[i]))
25
numberOfCodimensions++;
26
}
27
28
if (numberOfCodimensions == 0)
29
break;
30
31
int codimension = 0;
32
for (int i = 0, r = rand() % numberOfCodimensions; i < allowedMoves.size() && r >= 0; i++)
33
{
34
if (complex.hasValidMoves(allowedMoves[i]))
35
{
36
codimension = allowedMoves[i];
37
r--;
38
}
39
}
40
41
bistellar_move_list_t validMoves = complex.validMoves(codimension);
42
BistellarMove move = validMoves.at(rand() % validMoves.size());
43
complex.moveComplex(move);
44
}
45
}
46