3 * - By John Hodge (thePowersGang)
6 * - srand/rand/rand_p functions
11 unsigned int _rand_state_x = 123456789;
12 unsigned int _rand_state_y = 362436069;
13 unsigned int _rand_state_z = 521288629;
14 unsigned int _rand_state_w = 88675123;
17 int rand_p(unsigned int *seedp)
19 const int const_a = 0x731ADE, const_c = 12345;
21 *seedp = *seedp * const_a + const_c;
25 void srand(unsigned int seed)
27 _rand_state_x = rand_p( &seed );
28 _rand_state_y = rand_p( &seed );
29 _rand_state_z = rand_p( &seed );
30 _rand_state_w = rand_p( &seed );
37 t = _rand_state_x ^ (_rand_state_x << 11);
38 _rand_state_x = _rand_state_y; _rand_state_y = _rand_state_z; _rand_state_z = _rand_state_w;
39 return _rand_state_w = _rand_state_w ^ (_rand_state_w >> 19) ^ t ^ (t >> 8);