#include <random.h>
Public Member Functions | |
| RandomSource (const String &name) | |
| void | setSeed (uint32 seed) |
| uint32 | getSeed () const |
| uint | getRandomNumber (uint max) |
| uint | getRandomBit () |
| uint | getRandomNumberRng (uint min, uint max) |
| int | getRandomNumberRngSigned (int min, int max) |
Static Public Member Functions | |
| static uint32 | generateNewSeed () |
Xorshift* random number generator. Although it is definitely not suitable for cryptographic purposes, it serves our purposes just fine.
| Common::RandomSource::RandomSource | ( | const String & | name | ) |
Construct a new randomness source with the specific name. The name used must be globally unique, and is used to register the randomness source with the active event recorder, if any.
|
static |
Generates new seed based on the current date/time
| void Common::RandomSource::setSeed | ( | uint32 | seed | ) |
Set the seed used to initialize the RNG.
|
inline |
< Get a random seed that can be used to initialize the RNG.
| uint Common::RandomSource::getRandomNumber | ( | uint | max | ) |
Generate a random unsigned integer in the interval [0, max].
| max | The upper bound |
| uint Common::RandomSource::getRandomBit | ( | ) |
Generate a random bit, i.e. either 0 or 1. Identical to getRandomNumber(1), but potentially faster.
| uint Common::RandomSource::getRandomNumberRng | ( | uint | min, |
| uint | max | ||
| ) |
Generate a random unsigned integer in the interval [min, max].
| min | The lower bound. |
| max | The upper bound. |
| int Common::RandomSource::getRandomNumberRngSigned | ( | int | min, |
| int | max | ||
| ) |
Generates a random signed integer in the interval [min, max].
| min | the lower bound |
| max | the upper bound |