Thrive
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
thrive::RNG Class Referencefinal

Random Number Generator. More...

#include <rng.h>

Classes

struct  Implementation
 

Public Types

using Seed = unsigned int
 Typedef for seed values.
 

Public Member Functions

 RNG ()
 Constructor using proper random seed.
 
 RNG (Seed seed)
 Constructor. More...
 
 ~RNG ()
 Destructor.
 
void setSeed (Seed seed)
 Restarts the RNG with provided seed. More...
 
Seed getSeed () const
 Returns the current seed. More...
 
Seed generateRandomSeed ()
 Generates a proper random seed. More...
 
double getDouble (double min, double max)
 Generates a random double between min and max. More...
 
int getInt (int min, int max)
 Generates a random integer between min and max. More...
 
template<typename iterType >
void shuffle (iterType first, iterType last)
 Shuffles iterable collection. More...
 

Static Public Member Functions

static luabind::scope luaBindings ()
 Lua bindings. More...
 

Detailed Description

Random Number Generator.

Uses C++11 RNG features for optimal quality RNG.

Constructor & Destructor Documentation

RNG::RNG ( Seed  seed)

Constructor.

Parameters
seedThe seed used for initializing the RNG

Member Function Documentation

RNG::Seed RNG::generateRandomSeed ( )

Generates a proper random seed.

Returns
Seed with high amount of entropy
double RNG::getDouble ( double  min,
double  max 
)

Generates a random double between min and max.

Returns
Double in range [min, max]
int RNG::getInt ( int  min,
int  max 
)

Generates a random integer between min and max.

Returns
int in range [min, max] inclusive
RNG::Seed RNG::getSeed ( ) const

Returns the current seed.

Returns
The used seed
luabind::scope RNG::luaBindings ( )
static

Lua bindings.

Exposes:

void RNG::setSeed ( Seed  seed)

Restarts the RNG with provided seed.

Parameters
seedThe seed used for reinitializing the RNG
template<typename iterType >
void thrive::RNG::shuffle ( iterType  first,
iterType  last 
)
inline

Shuffles iterable collection.

Template Parameters
iterTypeIterator type
Returns
int in range [min, max] inclusive

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