I' currently implementing Eller's Algorithm into C++ and a little detail has being bothering me about the randomness of the maze.
Until now I've being using the following code for generating a random boolean:
bool randomBool() {
return 0 + (rand() % (1 - 0 + 1)) == 1;
}
//In main.cpp
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
But upon debugging I often see repeated 'true' or 'false" being generated, sometimes up to 30 times in a row.
Is this algorithm truly random and is there a better random generation in c++?
Aucun commentaire:
Enregistrer un commentaire