SuperTuxKart
|
A random number generator. More...
#include <random_generator.hpp>
Public Member Functions | |
int | get (int n) |
Returns a pseudo random number between 0 and n-1 inclusive. | |
void | seed (int s) |
Private Attributes | |
unsigned int | m_random_value |
unsigned int | m_a |
unsigned int | m_c |
Static Private Attributes | |
static std::vector< RandomGenerator * > | m_all_random_generators |
A random number generator.
Each objects that needs a random number uses its own number random generator. They are all seeded with number provided by the server. This guarantees that in a network game all 'random' values are actually identical among all machines. The formula used is x(n+1)=(a*x(n)+c) % m, but m is assumed to be 2^32, so the modulo operation can be skipped (for 4 byte integers).