stmm-games-doc  0.32.0
Public Member Functions | List of all members
stmg::RandomSource Class Referenceabstract
Inheritance diagram for stmg::RandomSource:
Inheritance graph
[legend]

Public Member Functions

virtual ~RandomSource () noexcept=default
 
virtual int32_t random (int32_t nFrom, int32_t nTo) noexcept=0
 Return a random value within a range. More...
 

Constructor & Destructor Documentation

◆ ~RandomSource()

virtual stmg::RandomSource::~RandomSource ( )
virtualdefaultnoexcept

Member Function Documentation

◆ random()

virtual int32_t stmg::RandomSource::random ( int32_t  nFrom,
int32_t  nTo 
)
pure virtualnoexcept

Return a random value within a range.

All entities within the game should use the same implementation of this function to generate random numbers (and not keep a personal generator alongside) so that the sequences can potentially be recorded and reproduced for debugging.

Parameters
nFromThe first of the possible values.
nToThe last of the possible values.
Returns
The random value >= nFrom and <= nTo.

Implemented in stmg::Game, and stmg::StdRandomSource.