File rng.hpp

class RNG
#include <rng.hpp>

Implements a fast random number generator using 32 bit XOR shifts (see “Xorshift RNGs”, Marsaglia, 2003).

Public Functions

RNG(uint32 randomState)
Parameters:

randomState – The seed to be used by the random number generator. Must be at least 1

uint32 randomInt(uint32 min, uint32 max)

Generates and returns a random number in [min, max).

Parameters:
  • min – The minimum number (inclusive)

  • max – The maximum number (exclusive)

Returns:

The random number that has been generated

bool randomBool()

Generates and returns a random boolean.

Returns:

The random boolean that has been generated

Private Members

uint32 randomState_
class RNGFactory
#include <rng.hpp>

A factory that allows to create instances of the type RNG.

Public Functions

RNGFactory(uint32 randomState)
Parameters:

randomState – The seed to be used by the random number generators. Must be at least 1

std::unique_ptr<RNG> create() const

Creates and returns a new object of type RNG.

Returns:

An unique pointer to an object of type RNG that has been created

Private Members

const uint32 randomState_
class RNGConfig
#include <rng.hpp>

Allows to configure random number generators.

Public Functions

RNGConfig()
uint32 getRandomState() const

Returns the seed that is used by random number generators.

Returns:

The seed that is used

RNGConfig &setRandomState(uint32 randomState)

Sets the seed that should be used by random number generators.

Parameters:

randomState – The seed that should be used. Must be at least 1

std::unique_ptr<RNGFactory> createRNGFactory() const

Creates and returns a new object of type RNGFactory according to this configuration.

Returns:

An unique pointer to an object of type RNGFactory that has been created

Private Members

uint32 randomState_