IAtari
Genetic algorithm generating AI capable to play Atari2600 games.
Utils::Random Class Reference

RNG based on Xoroshiro128+. More...

#include <Random.h>

Public Types

using result_type = std::uint64_t
 

Public Member Functions

 Random ()=delete
 Free the pointed object. More...
 
 Random (std::uint64_t seed=0)
 Initialize the random number generator with a seed. More...
 
void seedrandom (std::uint64_t s)
 Initialize state of xoroshiro128+ by transforming the seed with the splitmix64 algorithm. More...
 
std::uint32_t randfix ()
 Check that the random number will be generated in a correct range, then generate it. More...
 
std::uint64_t randuint64 ()
 Generate raw random number. More...
 
std::uint64_t randuint64 (const std::uint64_t max)
 Generate random number between [0, max-1] using uniform_int_distribution. More...
 
result_type operator() ()
 Generate a raw random number, part of UniformRandomBitGenerator interface. More...
 

Static Public Member Functions

static Randomget_Rng (void)
 Get a copy of the current thread. More...
 
static constexpr result_type min ()
 Min integer value, part of UniformRandomBitGenerator interface. More...
 
static constexpr result_type max ()
 Max integer value, part of UniformRandomBitGenerator interface. More...
 

Private Member Functions

std::uint64_t gen (void)
 Generate random generated number with Xoroshiro128+. More...
 

Private Attributes

std::uint64_t m_s [2]
 

Detailed Description

RNG based on Xoroshiro128+.

Author
Gian-Carlo Pascutto

Member Typedef Documentation

◆ result_type

using Utils::Random::result_type = std::uint64_t

Constructor & Destructor Documentation

◆ Random() [1/2]

Utils::Random::Random ( )
delete

Free the pointed object.

◆ Random() [2/2]

Utils::Random::Random ( std::uint64_t  seed = 0)

Initialize the random number generator with a seed.

Parameters
seedThe value of the seed

Member Function Documentation

◆ gen()

Utils::Random::gen ( void  )
private

Generate random generated number with Xoroshiro128+.

Returns
Random generated number

◆ get_Rng()

Utils::Random::get_Rng ( void  )
static

Get a copy of the current thread.

Returns
A thread local RNG

◆ max()

Utils::Random::max ( )
inlinestatic

Max integer value, part of UniformRandomBitGenerator interface.

Returns
Highest uint64_t value

◆ min()

Utils::Random::min ( )
inlinestatic

Min integer value, part of UniformRandomBitGenerator interface.

Returns
Lowest uint64_t value

◆ operator()()

Utils::Random::operator() ( )
inline

Generate a raw random number, part of UniformRandomBitGenerator interface.

Returns
The random generated number

◆ randfix()

std::uint32_t Utils::Random::randfix< 2 > ( )
inline

Check that the random number will be generated in a correct range, then generate it.

Returns
Random generated number between [0, max-1]

◆ randuint64() [1/2]

Utils::Random::randuint64 ( )

Generate raw random number.

Returns
The random generated number

◆ randuint64() [2/2]

Utils::Random::randuint64 ( const std::uint64_t  max)

Generate random number between [0, max-1] using uniform_int_distribution.

Returns
The random generated number

◆ seedrandom()

Utils::Random::seedrandom ( std::uint64_t  s)

Initialize state of xoroshiro128+ by transforming the seed with the splitmix64 algorithm.

Parameters
sThe value of the seed

Member Data Documentation

◆ m_s

std::uint64_t Utils::Random::m_s[2]
private

Array used to compute random numbers


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