OpenXcom
1.0
Open-source clone of the original X-Com
|
Random Number Generator used throughout the game for all your randomness needs. More...
Functions | |
uint64_t | getSeed () |
Returns the current seed in use by the generator. More... | |
void | setSeed (uint64_t n) |
Changes the current seed in use by the generator. More... | |
int | generate (int min, int max) |
Generates a random integer number within a certain range. More... | |
double | generate (double min, double max) |
Generates a random decimal number within a certain range. More... | |
double | boxMuller (double m, double s) |
Normal random variate generator. More... | |
bool | percent (int value) |
Generates a random percent chance of an event occuring, and returns the result. More... | |
int | generateEx (int max) |
Generates a random positive integer up to a number. More... | |
template<typename T > | |
void | shuffle (T &list) |
Shuffles a list randomly. More... | |
Random Number Generator used throughout the game for all your randomness needs.
Uses a 64-bit xorshift pseudorandom number generator.
double OpenXcom::RNG::boxMuller | ( | double | m, |
double | s | ||
) |
Normal random variate generator.
Get normally distributed value.
m | mean |
s | standard deviation |
int OpenXcom::RNG::generate | ( | int | min, |
int | max | ||
) |
Generates a random integer number within a certain range.
Generates a random integer number, inclusive.
min | Minimum number, inclusive. |
max | Maximum number, inclusive. |
double OpenXcom::RNG::generate | ( | double | min, |
double | max | ||
) |
Generates a random decimal number within a certain range.
Generates a random floating-point number.
min | Minimum number. |
max | Maximum number. |
int OpenXcom::RNG::generateEx | ( | int | max | ) |
Generates a random positive integer up to a number.
Generates a random integer number, exclusive.
max | Maximum number, exclusive. |
uint64_t OpenXcom::RNG::getSeed | ( | ) |
Returns the current seed in use by the generator.
Gets the seed in use.
bool OpenXcom::RNG::percent | ( | int | value | ) |
Generates a random percent chance of an event occuring, and returns the result.
Generates a percentage chance.
value | Value percentage (0-100%) |
void OpenXcom::RNG::setSeed | ( | uint64_t | n | ) |
Changes the current seed in use by the generator.
Sets the seed in use.
n | New seed. |
void OpenXcom::RNG::shuffle | ( | T & | list | ) |
Shuffles a list randomly.
Randomly changes the orders of the elements in a list.
list | The container to randomize. |