OpenEnroth 73e68f7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
RandomEngine Class Referenceabstract

#include <RandomEngine.h>

Inheritance diagram for RandomEngine:
MersenneTwisterRandomEngine SequentialRandomEngine TracingRandomEngine

Public Member Functions

virtual ~RandomEngine ()=default
 
virtual float randomFloat ()=0
 
virtual int random (int hi)=0
 
virtual int peek (int hi) const =0
 
virtual void seed (int seed)=0
 
int randomInSegment (int min, int max)
 
int randomDice (int count, int faces)
 
bool randomBool ()
 
template<class Range , class T = typename Range::value_type>
randomSample (const Range &range)
 
template<class T >
randomSample (std::initializer_list< T > range)
 

Detailed Description

Random number generator interface.

Note that the methods of this class are NOT thread-safe, unlike their libc counterparts.

Constructor & Destructor Documentation

◆ ~RandomEngine()

virtual RandomEngine::~RandomEngine ( )
virtualdefault

Member Function Documentation

◆ peek()

virtual int RandomEngine::peek ( int  hi) const
pure virtual

Note that this method is mainly for debugging, implementation is not required to be efficient.

Parameters
hiUpper bound for the result. Must be greater than zero.
Returns
Random number that the next call to random(hi) will return.

Implemented in TracingRandomEngine, MersenneTwisterRandomEngine, and SequentialRandomEngine.

◆ random()

virtual int RandomEngine::random ( int  hi)
pure virtual
Parameters
hiUpper bound for the result. Must be greater than zero.
Returns
Random number in range [0, hi).

Implemented in TracingRandomEngine, MersenneTwisterRandomEngine, and SequentialRandomEngine.

◆ randomBool()

bool RandomEngine::randomBool ( )
inline
Returns
Random binary value.

◆ randomDice()

int RandomEngine::randomDice ( int  count,
int  faces 
)
Original binary offset:
0x00452B2E
Parameters
countNumber of dice to throw.
facesNumber of faces on each die.
Returns
Result of throwing the dice.

◆ randomFloat()

virtual float RandomEngine::randomFloat ( )
pure virtual
Returns
Random floating point number in range [0, 1).

Implemented in TracingRandomEngine, MersenneTwisterRandomEngine, and SequentialRandomEngine.

◆ randomInSegment()

int RandomEngine::randomInSegment ( int  min,
int  max 
)
Parameters
minMinimal result value.
maxMaximal result value. Must be greater or equal to min.
Returns
Random number in closed interval [min, max]. Note that both min and max are included in the interval.

◆ randomSample() [1/2]

template<class Range , class T = typename Range::value_type>
T RandomEngine::randomSample ( const Range &  range)
inline
Parameters
rangeRandom access range.
Returns
Random element from the provided range.

◆ randomSample() [2/2]

template<class T >
T RandomEngine::randomSample ( std::initializer_list< T >  range)
inline

◆ seed()

virtual void RandomEngine::seed ( int  seed)
pure virtual

Reinitializes this random engine with the provided seed value. Passing 0 should be equivalent to calling an in-place destructor and then reconstructing the object.

Parameters
seedRandom seed.

Implemented in TracingRandomEngine, MersenneTwisterRandomEngine, and SequentialRandomEngine.


The documentation for this class was generated from the following files: