openMSX
|
#include <random>
Go to the source code of this file.
Classes | |
struct | PCG< SEED > |
Functions | |
auto & | global_urng () |
Return reference to a (shared) global random number generator. | |
void | randomize () |
Seed the (shared) random number generator. | |
bool | random_bool () |
Return a random boolean value. | |
int | random_int (int from, int thru) |
Return a random integer in the range [from, thru] (note: closed interval). | |
float | random_float (float from, float upto) |
Return a random float in the range [from, upto) (note: half-open interval). | |
uint32_t | random_32bit () |
Return a random 32-bit value. | |
constexpr float | getCanonicalFloat (uint32_t u) |
|
inline |
Return reference to a (shared) global random number generator.
Definition at line 8 of file random.hh.
Referenced by openmsx::GLSnow::GLSnow(), random_32bit(), random_bool(), random_float(), random_int(), and randomize().
|
inline |
Return a random 32-bit value.
This function should rarely be used. It should NOT be used if you actually need random values in a smaller range than [0 .. 0xffffffff]. For example: 'random_32bit % N' with
Definition at line 67 of file random.hh.
References global_urng().
|
inline |
|
inline |
Return a random float in the range [from, upto) (note: half-open interval).
This function is convenient if you only need a few random values. If you need a large amount it's a bit faster to create a local distribution object and reuse that for all your values.
Definition at line 50 of file random.hh.
References global_urng().
Referenced by openmsx::GLSnow::paint(), and openmsx::PostProcessor::rotateFrames().
|
inline |
Return a random integer in the range [from, thru] (note: closed interval).
This function is convenient if you only need a few random values. If you need a large amount it's a bit faster to create a local distribution object and reuse that for all your values.
Definition at line 38 of file random.hh.
References global_urng().
|
inline |
Seed the (shared) random number generator.
Definition at line 16 of file random.hh.
References global_urng().