SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
RandomGenerator Class Reference

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
 

Detailed Description

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).


The documentation for this class was generated from the following files: