Add an SDL random number generator with independent seeds.

This commit is contained in:
Glenn Maynard
2003-07-30 20:31:50 +00:00
parent f741443c76
commit 4262c7fd96
2 changed files with 23 additions and 4 deletions
+14
View File
@@ -25,6 +25,20 @@
unsigned long randseed = time(NULL);
RandomGen::RandomGen( unsigned long seed_ )
{
seed = seed_;
if(seed == 0)
seed = time(NULL);
}
int RandomGen::operator() ( int maximum )
{
seed = 1664525L * seed + 1013904223L;
return (seed >> 2) % (maximum + 1);
}
void fapproach( float& val, float other_val, float to_move )
{
ASSERT( to_move >= 0 );