Don't use rand()%n. The function specified by the ANSI committee is a terrible linear congruential generator. In fact, it's so bad that the low order bit alternates. The algorithm implemented as RandomFloat() seems to be Park and Miller's "minimum standard" generator which is better (but not great). [See Knuth for more information.]
Any place where you would use rand()%n, use RandomInt(0, n) instead.
This commit is contained in:
@@ -460,9 +460,9 @@ void PlayerOptions::ChooseRandomModifiers()
|
||||
float f;
|
||||
f = RandomFloat(0,1);
|
||||
if( f>0.66f )
|
||||
m_fAccels[rand()%NUM_ACCELS] = 1;
|
||||
m_fAccels[RandomInt(NUM_ACCELS)] = 1;
|
||||
else if( f>0.33f )
|
||||
m_fEffects[rand()%NUM_EFFECTS] = 1;
|
||||
m_fEffects[RandomInt(NUM_EFFECTS)] = 1;
|
||||
f = RandomFloat(0,1);
|
||||
if( f>0.95f )
|
||||
m_fAppearances[APPEARANCE_HIDDEN] = 1;
|
||||
|
||||
Reference in New Issue
Block a user