3#include <Infinity/api.h>
4#include <Infinity/Engine/PRNGDistribution.hpp>
6#include <pcg/pcg_random.hpp>
47class INFINITY_API_PUBLIC
PRNG
110 PRNG(uint64_t seed, uint64_t stream = 0);
126 void setSeed(uint64_t seed, uint64_t stream = 0);
133 inline uint64_t
getSeed()
const {
return _seed; }
155 inline uint32_t
operator()(uint32_t upper_bound) {
return _gen(upper_bound); }
162 inline uint32_t
next() {
return _gen(); }
210 static constexpr size_t period_pow2() {
return pcg32::period_pow2(); }
217 static constexpr uint32_t
min() {
return pcg32::min(); }
224 static constexpr uint32_t
max() {
return pcg32::max(); }
234 inline void advance(uint64_t delta) {
return _gen.advance(delta); }
243 inline void backstep(uint64_t delta) {
return _gen.backstep(delta); }
252 inline void discard(uint64_t delta) {
return _gen.discard(delta); }
Pseudo-random number generator for procedural generation.
Definition PRNG.hpp:48
uint32_t result_type
Result type for compatibility with standard library distributions.
Definition PRNG.hpp:50
float nextFloat()
Generates a random float value in the range [0, 1).
uint32_t next()
Generates the next random uint32 value.
Definition PRNG.hpp:162
void backstep(uint64_t delta)
Steps the generator state backward by delta steps.
Definition PRNG.hpp:243
uint32_t nextBounded(uint32_t l, uint32_t u)
Generates a random uint32 value within the specified inclusive range.
int nextIntBounded(int l, int u)
Generates a random integer value within the specified inclusive range.
float nextFloatBounded(float l, float u)
Generates a random float value within the specified inclusive range.
PRNG(uint64_t seed, uint64_t stream=0)
Constructs a PRNG with the specified seed and stream.
static constexpr uint32_t max()
Returns the maximum value the generator can produce.
Definition PRNG.hpp:224
void setSeed(uint64_t seed, uint64_t stream=0)
Sets the seed and stream for the random number generator.
int nextInt()
Generates a random integer value.
void discard(uint64_t delta)
Discards delta random values from the sequence.
Definition PRNG.hpp:252
uint32_t operator()(uint32_t upper_bound)
Function call operator for generating bounded random uint32 values.
Definition PRNG.hpp:155
uint64_t getSeed() const
Gets the current seed value.
Definition PRNG.hpp:133
uint64_t getStream() const
Gets the current stream identifier.
Definition PRNG.hpp:140
static uint64_t createSeed()
Creates a new random seed using system entropy.
uint32_t operator()()
Function call operator for generating random uint32 values.
Definition PRNG.hpp:147
static constexpr size_t period_pow2()
Returns the period of the generator as a power of 2.
Definition PRNG.hpp:210
void advance(uint64_t delta)
Advances the generator state forward by delta steps.
Definition PRNG.hpp:234
PRNG()
Default constructor.
static constexpr uint32_t min()
Returns the minimum value the generator can produce.
Definition PRNG.hpp:217
Definition BaseException.hpp:9