|
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. | |
Static Public Member Functions | |
| static std::mt19937 & | getGenerator () |
| Return a reference to the thread-local generator. | |
| static void | seed (int s) |
Static Private Attributes | |
| static unsigned int | m_random_value = RandomGenerator::default_seed |
| static constexpr unsigned int | default_seed = 3141591 |
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).