Pseudo-random number generator. More...
#include <sifteo/math.h>
Public Member Functions | |
bool | chance (float probability) |
Take a chance. Returns a boolean that has a 'probability' chance of being 'true'. More... | |
float | expovariate (float averageInterval) |
Returns a generated pseudorandom inverval for a poisson process (e.g. whack-a-mole timing). | |
template<typename T > | |
T | randint (T a, T b) |
Returns a uniformly distributed random integer in the range [a, b], including both end points. | |
Random () | |
Construct a new random number generator, using an arbitrary seed. | |
Random (uint32_t s) | |
Construct a new random number generator with a well-defined seed. | |
float | random () |
Returns a uniformly distributed floating point number between 0 and 1, inclusive. | |
template<typename T > | |
T | randrange (T a, T b) |
Returns a uniformly distributed random integer in the half-open interval [a, b), including the lower but not the upper end point. | |
template<typename T > | |
T | randrange (T count) |
The one-argument variant of randrange() always starts at zero, and returns an integer up to but not including 'count'. More... | |
uint32_t | raw () |
Returns the next raw 32-bit pseudo-random number. | |
void | seed (uint32_t s) |
Re-seed this random number generator. More... | |
void | seed () |
Re-seed this random number generator arbitrarily. More... | |
float | uniform (float a, float b) |
Returns a uniformly distributed floating point number in the range [a, b) or [a, b], depending on rounding. | |
Pseudo-random number generator.
Each instance of the Random class has a distinct PRNG state.
When possible, method semantics here have been designed to match those used by Python's "random" module.
|
inline |
Take a chance. Returns a boolean that has a 'probability' chance of being 'true'.
If the argument is constant, all floating point math folds away at compile-time. For values of 0 and 1, we are guaranteed to always return false or true, respectively.
|
inline |
The one-argument variant of randrange() always starts at zero, and returns an integer up to but not including 'count'.
Guaranteed to be capable of returning 'count' distinct values, starting at zero.
|
inline |
Re-seed this random number generator.
For a given seed, the subsequent random numbers are guaranteed to be deterministic.
|
inline |
Re-seed this random number generator arbitrarily.
This implementation uses the system's nanosecond timer.
Sifteo SDK v1.1.0 (see all versions)
Last updated Tue Dec 23 2014, by Doxygen