Aus dem Link von danimath:
Knuth suggests various generators, including one that combines the first two table entries above:
- xn+1 = 48271*xn mod (231 - 1),
yn+1 = 40692*yn mod (231 - 249),
zn = (xn - yn) mod (231 - 1),
Ok, diesen Generator habe ich nun mal verwendet
Code:
unsigned long lastrandom1,lastrandom2;
unsigned long random()
{
unsigned long z=(lastrandom1-lastrandom2)%2147483647; // 2^31-1
lastrandom1=(48271*lastrandom1)%2147483647;
lastrandom2=(40692*lastrandom2)%2147483399; // 2^31-249
return z;
}
// Seed:
time_t t;
time(&t);
srand((unsigned int)t);
lastrandom1=rand();
lastrandom2=rand();
Und sieheda, auch wenn der Generator nicht perfekt ist, lässt sich damit kein Vorteil beim Spiel "mit system" mehr feststellen.
Lesezeichen