A random number generator base class. More...
Public Member Functions | |
const Burger::StaticRTTI * | get_StaticRTTI (void) const noexcept override |
Get the description to the class. | |
virtual void | set_seed (uint32_t uNewSeed) noexcept=0 |
Seed the random number generator. | |
virtual uint32_t | get (void) noexcept=0 |
Return a 32 bit pseudo random number. | |
uint32_t | get_seed (void) const noexcept |
Return the random number seed. | |
void | random_seed (void) noexcept |
Seed with a random value. | |
uint32_t | get_uint32 (uint32_t uRange) noexcept |
Return a 32 bit random number. | |
uint32_t | get_dice (uint32_t uDiceCount, uint32_t uDiceSize) noexcept |
Return a dice roll. | |
int32_t | get_int32 (uint32_t uRange) noexcept |
Return a signed value in a specific range. | |
float | get_float (void) noexcept |
Return a float from 0.0f to 0.99999f. | |
float | get_float (float fRange) noexcept |
Return a float from 0.0f to fRange. | |
float | get_symmetric_float (void) noexcept |
Return a float from -.0.99999f to 0.99999f. | |
float | get_symmetric_float (float fRange) noexcept |
Return a float from -fRange to fRange. | |
double | get_double (void) noexcept |
Return a double from 0.0 to 0.999999999. | |
Public Member Functions inherited from Burger::Base | |
const char * | get_class_name (void) const noexcept |
Get the name of the class. | |
virtual | ~Base () noexcept=default |
Destructor. | |
Static Public Attributes | |
static const Burger::StaticRTTI | g_StaticRTTI |
The global description of the class. | |
Static Public Attributes inherited from Burger::Base | |
static const Burger::StaticRTTI | g_StaticRTTI |
The global description of the class. | |
Protected Attributes | |
uint32_t | m_uSeed |
Random number seed. | |
A random number generator base class.
This class is what all random number generators derive from so that many random number generator algorithms can share common code.
|
pure virtualnoexcept |
Return a 32 bit pseudo random number.
Get a pseudo random number using the current algorithm. Return a 32 bit unsigned value.
Implemented in Burger::Random, and Burger::RandomMersenneTwist.
|
noexcept |
Return a dice roll.
Given the number of dice and the size of the dice, "roll" the dice and return the result.
Examples: get_dice(1,4) will yield 1-4 evenly spread get_dice(2,4) will yield 2-8 with 5 having the highest probability based on the curve
If either input value is 0, the result is zero.
If the dice roll exceeds a uint32_t, UINT32_MAX is returned
uDiceCount | Number of dice to roll. |
uDiceSize | Number of sides on each die. |
|
noexcept |
Return a double from 0.0 to 0.999999999.
Returns a random number in the range of 0.0 to 0.999999. The numbers are spread evenly with 53 bit resolution.
|
noexcept |
Return a float from 0.0f to fRange.
Returns a random number in the range of 0.0f to fRange. The numbers are spread evenly.
|
noexcept |
Return a float from 0.0f to 0.99999f.
Returns a random number in the range of 0.0f to 0.999999f. The numbers are spread evenly.
|
noexcept |
Return a signed value in a specific range.
Return a random number between -Range and +Range (Inclusive) and it's a SIGNED value. If Range = 3, then the value returned is -2 to 2 inclusive. 0, and numbers higher than 0x7FFFFFFFU are illegal.
uRange | Range from 1 to MAX_INT-1. |
|
inlinenoexcept |
Return the random number seed.
Get seed value for this pseudo random number generator.
|
overridevirtualnoexcept |
Get the description to the class.
This virtual function will pull the pointer to the StaticRTTI instance that has the name of the class. Due to it being virtual, it will be the name of the most derived class.
Reimplemented from Burger::Base.
Reimplemented in Burger::RandomMersenneTwist.
|
noexcept |
Return a float from -fRange to fRange.
Returns a random number in the range of -fRange to fRange. The numbers are spread evenly.
|
noexcept |
Return a float from -.0.99999f to 0.99999f.
Returns a random number in the range of -.0.99999f to 0.999999f. The numbers are spread evenly.
|
noexcept |
Return a 32 bit random number.
Get a random number. Return a number between 0 through (Range-1) inclusive.
uRange | 0 means return 32 bits as is, anything else means return 0 through (Range-1) inclusive. |
|
noexcept |
Seed with a random value.
Init the random number generator with an "Anything goes" policy so programs will power up in an unknown state. Do NOT use this if you wish your title to have recordable demos.
This function will start with the current time as a seed and then it will use a formula that assumes that the tick timer runs at a constant time base but the machine in question does not. As a result, the number of times get() is called is anyone's guess.
|
pure virtualnoexcept |
Seed the random number generator.
Set the random number generator to a specific seed. This allows altering the random number flow in a controlled manner.
uNewSeed | 32 bit seed value. |
Implemented in Burger::Random, and Burger::RandomMersenneTwist.
|
static |
The global description of the class.
This record contains the name of this class and a reference to the parent
|
protected |
Random number seed.