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:
@@ -131,12 +131,12 @@ void ScoreKeeperRave::LaunchAttack( AttackLevel al )
|
||||
RString sAttackToGive;
|
||||
|
||||
if (GAMESTATE->m_pCurCharacters[pn] != NULL)
|
||||
sAttackToGive = asAttacks[ rand()%NUM_ATTACKS_PER_LEVEL ];
|
||||
sAttackToGive = asAttacks[ RandomInt(NUM_ATTACKS_PER_LEVEL) ];
|
||||
else
|
||||
{
|
||||
/* If you add any note skins here, you need to make sure they're cached, too. */
|
||||
RString DefaultAttacks[8] = { "1.5x", "2.0x", "0.5x", "reverse", "sudden", "boost", "brake", "wave" };
|
||||
sAttackToGive = DefaultAttacks[ rand()%8 ];
|
||||
sAttackToGive = DefaultAttacks[ RandomInt(8) ];
|
||||
}
|
||||
|
||||
PlayerNumber pnToAttack = OPPOSITE_PLAYER[pn];
|
||||
|
||||
Reference in New Issue
Block a user