nCine::RandomGenerator class

PCG32 pseudo-random number generator.

Generates uniformly distributed integers, floats and booleans from a 64-bit state and sequence. The Fast() and FastFloat() variants trade statistical uniformity for speed.

Constructors, destructors, conversion operators

RandomGenerator() noexcept
Creates a generator seeded with default values.
RandomGenerator(std::uint64_t initState, std::uint64_t initSequence) noexcept
Creates a generator seeded with the specified state and sequence.

Public functions

void Init(std::uint64_t initState, std::uint64_t initSequence) noexcept
Reseeds the generator with the specified state and sequence.
auto Next() -> std::uint32_t noexcept
Returns a uniformly distributed 32-bit number.
auto Next(std::uint32_t min, std::uint32_t max) -> std::uint32_t noexcept
Returns a uniformly distributed 32-bit number r where min <= r < max.
auto NextFloat() -> float noexcept
Returns a uniformly distributed float r where 0 <= r < 1.
auto NextFloat(float min, float max) -> float noexcept
Returns a uniformly distributed float r where min <= r < max.
auto NextBool() -> bool noexcept
Returns a uniformly distributed boolean.
auto Fast(std::uint32_t min, std::uint32_t max) -> std::uint32_t noexcept
Faster but less uniform version of Next(std::uint32_t, std::uint32_t).
auto FastFloat() -> float noexcept
Faster but less uniform version of NextFloat().
auto FastFloat(float min, float max) -> float noexcept
Faster but less uniform version of NextFloat(float, float).
void Uuid(Containers::StaticArrayView<16, std::uint8_t> result)
Fills the buffer with a 128-bit unique identifier.
template<class T>
void Shuffle(Containers::ArrayView<T> data) noexcept
Shuffles the elements of the specified array in place.