MAGE  v0.171.0
Matthias Advanced Game Engine
mage::RNG Class Reference

#include <rng.hpp>

Public Member Functions

 RNG (U32 seed=606418532u) noexcept
 
 RNG (const RNG &rng) noexcept=default
 
 RNG (RNG &&rng) noexcept=default
 
 ~RNG ()=default
 
RNGoperator= (const RNG &rng)=delete
 
RNGoperator= (RNG &&rng)=delete
 
void Seed (U32 seed) noexcept
 
F32 Uniform () noexcept
 
F32 Uniform (F32 low, F32 high) noexcept
 

Private Attributes

std::minstd_rand m_generator
 
std::uniform_real_distribution< F32m_distribution
 

Detailed Description

A class of (uniform) random number generators (RNGs).

Constructor & Destructor Documentation

◆ RNG() [1/3]

mage::RNG::RNG ( U32  seed = 606418532u)
explicitnoexcept

Constructs a RNG with the given seed.

Parameters
[in]seedThe seed.

◆ RNG() [2/3]

mage::RNG::RNG ( const RNG rng)
defaultnoexcept

Constructs a RNG from the given RNG.

Parameters
[in]rngA reference to the RNG to copy.

◆ RNG() [3/3]

mage::RNG::RNG ( RNG &&  rng)
defaultnoexcept

Constructs a RNG by moving the given RNG.

Parameters
[in]rngA reference to the RNG to move.

◆ ~RNG()

mage::RNG::~RNG ( )
default

Destructs this RNG.

Member Function Documentation

◆ operator=() [1/2]

RNG& mage::RNG::operator= ( const RNG rng)
delete

Copies the given RNG to this RNG.

Parameters
[in]rngA reference to the RNG to copy.
Returns
A reference to the copy of the given RNG (i.e. this RNG).

◆ operator=() [2/2]

RNG& mage::RNG::operator= ( RNG &&  rng)
delete

Moves the given RNG to this RNG.

Parameters
[in]rngA reference to the RNG to move.
Returns
A reference to the moved RNG (i.e. this RNG).

◆ Seed()

void mage::RNG::Seed ( U32  seed)
noexcept

Seeds this RNG.

Parameters
[in]seedThe seed.

◆ Uniform() [1/2]

F32 mage::RNG::Uniform ( )
noexcept

Generates a uniform random number in [0,1).

Returns
A uniform random number in [0,1).

◆ Uniform() [2/2]

F32 mage::RNG::Uniform ( F32  low,
F32  high 
)
noexcept

Generates a uniform random number in [start,end).

Parameters
[in]lowThe lower (inclusive) bound of the interval.
[in]highThe upper (exclusive) bound of the interval.
Returns
A uniform random number in [start,end).

Member Data Documentation

◆ m_distribution

std::uniform_real_distribution< F32 > mage::RNG::m_distribution
private

The uniform real number distribution of this RNG.

◆ m_generator

std::minstd_rand mage::RNG::m_generator
private

The random number generator, Newer "Minimum standard", of this RNG. This LCG has a much smaller footprint compared to the default Mersenne Twister used in the std.