Game Development Reference
In-Depth Information
switch( GuessType ) {
case GUESS_33:
Guess = 33;
break;
case GUESS_22:
Guess = 22;
break;
case GUESS_RANDOM:
Guess = DieRoller.SingleDie( 101 );
break;
case GUESS_SEMI:
Guess =
DieRoller.RandomFromNormalDist( 0, 70, 0,
SKEW_RIGHT, 2 );
break;
} // end switch
return Guess;
}
The switch statement is fairly self-explanatory. If GUESS_TYPE is GUESS_33 ,
then the guess is 33. Likewise, if the guess type is 22, the guess is set to 22. In the
other two cases, we generate random guesses based on the parameters shown.
For example, if the guesser is one of those who is guessing randomly, we simply
ask our number generator for a number between 0 and 100 via the call DieRoller.
SingleDie( 101 ) . This returns a uniform distribution. All of the possibilities are
equal.
If the guesser is one of the semi-logical guessers we identified earlier in the
chapter, we ask for a random guess from the normal distribution called for by
the parameters:
Search WWH ::




Custom Search