Xiangiqgame
AI engine for Xiangqi
Loading...
Searching...
No Matches
boardstate::PseudoRandomKeyGenerator< IntType > Class Template Reference

Generates pseudorandom integers. More...

#include <key_generator.hpp>

Collaboration diagram for boardstate::PseudoRandomKeyGenerator< IntType >:
Collaboration graph

Public Member Functions

 PseudoRandomKeyGenerator ()
 
 PseudoRandomKeyGenerator (uint32_t seed)
 
IntType GenerateKey ()
 Generates a pseudorandom IntType value using mt19937.
 
std::random_device::result_type seed ()
 

Private Attributes

std::random_device::result_type seed_
 
std::mt19937 prng_
 

Detailed Description

template<typename IntType>
class boardstate::PseudoRandomKeyGenerator< IntType >

Generates pseudorandom integers.

Definition at line 17 of file key_generator.hpp.

Constructor & Destructor Documentation

◆ PseudoRandomKeyGenerator() [1/2]

template<typename IntType >
boardstate::PseudoRandomKeyGenerator< IntType >::PseudoRandomKeyGenerator ( )
inline

Definition at line 19 of file key_generator.hpp.

◆ PseudoRandomKeyGenerator() [2/2]

template<typename IntType >
boardstate::PseudoRandomKeyGenerator< IntType >::PseudoRandomKeyGenerator ( uint32_t  seed)
inline

Definition at line 23 of file key_generator.hpp.

Member Function Documentation

◆ GenerateKey()

template<typename IntType >
IntType boardstate::PseudoRandomKeyGenerator< IntType >::GenerateKey ( )
inline

Generates a pseudorandom IntType value using mt19937.

The 0xFFFFFFFF bit mask is used b/c std::mt19937 uses std::uint_fast32_t which is a 64-bit integer on 64-bit systems (but still only uses the lower 32 bits). See discussion at: https://stackoverflow.com/questions/63601328/why-do-std-implementations-of-mt19937-have-double-sizeof-as-boost-version

Definition at line 32 of file key_generator.hpp.

◆ seed()

template<typename IntType >
std::random_device::result_type boardstate::PseudoRandomKeyGenerator< IntType >::seed ( )
inline

Definition at line 43 of file key_generator.hpp.

Member Data Documentation

◆ prng_

template<typename IntType >
std::mt19937 boardstate::PseudoRandomKeyGenerator< IntType >::prng_
private

Definition at line 47 of file key_generator.hpp.

◆ seed_

template<typename IntType >
std::random_device::result_type boardstate::PseudoRandomKeyGenerator< IntType >::seed_
private

Definition at line 46 of file key_generator.hpp.


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