Main   Class List   Namespace List   Wiki

Random Numbers
[Math]

Functions for generating random numbers. More...

Functions

float getRandom (int a=1, int b=0)
 Get a random number between a and b.
int getRandomSeed ()
 Get the current seed used by the random number generator.
void setRandomSeed (int seed=-1)
 Set the current seed for the random number generator.

Detailed Description

Functions for generating random numbers.

Based on a seed, the random number generator produces a sequence of numbers. As a given seed will always produce the same sequence of numbers this can be used to generate re-producible sequences of apparently random numbers.

To set the seed, call setRandomSeed().


Function Documentation

float getRandom ( int  a = 1,
int  b = 0 
)

Get a random number between a and b.

Parameters:
a Lower bound on the random number. The random number will be >= a.
b Upper bound on the random number. The random number will be <= b.
Returns:
A pseudo-random number between a and b.
See also:
setRandomSeed
int getRandomSeed (  ) 

Get the current seed used by the random number generator.

Returns:
The current random number generator seed value.
void setRandomSeed ( int  seed = -1  ) 

Set the current seed for the random number generator.

Based on this seed, a repeatable sequence of numbers will be produced by getRandom().

Parameters:
seed The seed with which to initialize the randon number generator with. The same seed will always leed tothe same sequence of pseudo-random numbers. If -1, the current timestamp will be used as the seed which is a good basis for randomization.


Copyright © GarageGames, LLC. All Rights Reserved.