I need to implement a good RNG and I guess Mersenne Twister could be good for me.
I didn't find anywhere a working C++ implementation, am I a bad google searcher or is it really not simple to find?!
I've tried before rand()
:
srand((unsigned)time(0));
for (int i = 0; i < 9; i++) {
random = rand();
cout<<random;
}
I don't know why, but the random variable is always the same number.....BUT if I add a Sleep(1000)
, it works! Like this:
srand((unsigned)time(0));
for (int i = 0; i < 9; i++) {
random = rand();
cout<<random;
Sleep(1000);
}
So I decided to try Mersenne Twister...Could someone find a solution of this (because I need to find a very very big number of random numbers so I can't use Sleep(1000)
, it would takes eras!) or help me to implement Mersenne Twister or maybe also another good RNG.
Thanks and sorry for my bad English...