#include <Random.h>
An interface for easy PRNG interaction.
Creates a new Random instance that is ready to be used.
MFM::Random::Random |
( |
u32 |
seed | ) |
|
|
inline |
Creates a new Random instance, initialized using a specified seed.
s32 MFM::Random::Between |
( |
s32 |
min, |
|
|
s32 |
max |
|
) |
| |
|
inline |
Return a uniformly chosen pseudo-random signed number in the range of min..max, with both endpoints included. between(-1,1) returns -1, 0, and 1 equally often. FAILs with ILLEGAL_ARGUMENT if max<min.
u32 MFM::Random::Create |
( |
| ) |
|
|
inline |
Gets 32 well-mixed pseudo-random bits from this internal PRNG .
- Returns
- a 32-bit word containing pseudo-random bits.
u32 MFM::Random::Create |
( |
u32 |
max | ) |
|
|
inline |
Gets a uniform pseudo-random number from 0..max-1. FAILs ILLEGAL_ARGUMENT if max==0.
- Parameters
-
max | The exclusive upper bound of the generated number. |
- Returns
- A pseudo-random number in the range [0, max) .
bool MFM::Random::CreateBool |
( |
| ) |
|
|
inline |
Generates a pseudo-random boolean value.
- Returns
- Either
true
or false
, determined pseudo-randomly.
bool MFM::Random::OddsOf |
( |
u32 |
thisMany, |
|
|
u32 |
outOfThisMany |
|
) |
| |
|
inline |
Return true pseudo-randomly. with thisMany times outOfThisMany times. E.g., oddsOf(1,10) returns true on 10% of calls. When thisMany == 0, never returns true. When thisMany >= outOfThisMany, always returns true. FAILs ILLEGAL_ARGUMENT if outOfThisMany is 0.
template<int P>
bool MFM::Random::OddsOf |
( |
FXP< P > |
thisMany, |
|
|
FXP< P > |
outOfThisMany |
|
) |
| |
|
inline |
Return true pseudo-randomly, with fixed point bounds. E.g., oddsOf(FXP16(0.6),FXP16(2)) returns true on 30% of calls. FAILs ILLEGAL_ARGUMENT if outOfThisMany is <= 0. When thisMany <= 0, never returns true. When thisMany >= outOfThisMany, always returns true.
bool MFM::Random::OneIn |
( |
u32 |
odds | ) |
|
|
inline |
Return true pseudo-randomly. with a chance of 1-in-odds. E.g., oneIn(10) returns true on 10% of calls. When odds == 1, always returns true. FAILs ILLEGAL_ARGUMENT if odds is 0.
void MFM::Random::SetSeed |
( |
u32 |
seed | ) |
|
|
inline |
Resets the seed for the PRNG to a given seed.
- Parameters
-
seed | The seed to set the internal PRNG to. |
The documentation for this class was generated from the following file: