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:
@@ -160,7 +160,7 @@ void DancingCharacters::LoadNextSong()
|
||||
m_pCharacter[p]->PlayAnimation( "rest" );
|
||||
}
|
||||
|
||||
int Neg1OrPos1() { return rand()%2 ? -1 : +1; }
|
||||
int Neg1OrPos1() { return RandomInt( 2 ) ? -1 : +1; }
|
||||
|
||||
void DancingCharacters::Update( float fDelta )
|
||||
{
|
||||
@@ -213,7 +213,7 @@ void DancingCharacters::Update( float fDelta )
|
||||
// time for a new sweep?
|
||||
if( GAMESTATE->m_fSongBeat > m_fThisCameraEndBeat )
|
||||
{
|
||||
if( (rand()%5) >= 2 )
|
||||
if( RandomInt(5) >= 2 )
|
||||
{
|
||||
// sweeping camera
|
||||
m_CameraDistance = CAMERA_SWEEP_DISTANCE + RandomInt(-1,1) * CAMERA_SWEEP_DISTANCE_VARIANCE;
|
||||
|
||||
Reference in New Issue
Block a user