]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/client/prandom.qc
prandom() - an attempt to make random decisions predictable (not sure if it actually...
[divverent/nexuiz.git] / data / qcsrc / client / prandom.qc
1 // prandom - PREDICTABLE random number generator
2
3 float prandom_time, prandom_seed;
4 float prandom()
5 {
6         float c;
7
8         // reinitialize every frame to make it act similar every frame
9         if(time != prandom_time)
10                 prandom_seed = prandom_time = time;
11         
12         c = crc16(FALSE, strcat(ftos(prandom_seed), ftos(prandom_seed + 3.1415926535)));
13         prandom_seed = c;
14         return c / 65536; // in [0..1[
15 }