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

Uses Zobrist hashing to calculate a "reasonably unique" integer value for each board configuration encountered during a game. More...

#include <zobrist_calculator_for_concepts.hpp>

Collaboration diagram for boardstate::ZobristCalculatorForConcepts< K >:
Collaboration graph

Public Types

using KeyType = K
 

Public Member Functions

KeyType board_state () const
 
uint32_t seed () const
 
void FullBoardStateCalc (const gameboard::BoardMap_t &board_map)
 
void UpdateBoardState (const gameboard::ExecutedMove &executed_move)
 

Static Public Member Functions

static std::shared_ptr< ZobristCalculatorForConcepts< K > > Create (uint32_t seed=std::random_device{}())
 

Private Types

using PieceZarray_t = array< array< K, gameboard::kNumFiles >, gameboard::kNumRanks >
 
using TeamZarray_t = array< PieceZarray_t, gameboard::kNumPieceTypeVals >
 
using GameZarray_t = array< TeamZarray_t, 2 >
 

Private Member Functions

 ZobristCalculatorForConcepts (uint32_t seed=std::random_device{}())
 Constructs a ZobristCalculatorForConcepts.
 
GetHashValueAt (PieceColor color, PieceType piece_type, BoardSpace space)
 
void FullBoardStateCalcInternal (const gameboard::BoardMap_t &board_map)
 
void UpdateBoardStateInternal (const gameboard::ExecutedMove &executed_move)
 

Static Private Member Functions

static const GameZarray_t CreateGameZarray (PseudoRandomKeyGenerator< K > &key_generator)
 Static helper method for building 4-D array of Zobrist keys in constuctor.
 

Private Attributes

GameZarray_t zarray_
 
turn_key_
 
uint32_t seed_
 
board_state_
 

Detailed Description

template<typename K>
class boardstate::ZobristCalculatorForConcepts< K >

Uses Zobrist hashing to calculate a "reasonably unique" integer value for each board configuration encountered during a game.

K can be any unsigned integer type with a size = (n * 32 bits) where n is an integer >= 1.

Definition at line 13 of file zobrist_calculator_for_concepts.hpp.

Member Typedef Documentation

◆ GameZarray_t

template<typename K >
using boardstate::ZobristCalculatorForConcepts< K >::GameZarray_t = array<TeamZarray_t, 2>
private

Definition at line 19 of file zobrist_calculator_for_concepts.hpp.

◆ KeyType

template<typename K >
using boardstate::ZobristCalculatorForConcepts< K >::KeyType = K

Definition at line 27 of file zobrist_calculator_for_concepts.hpp.

◆ PieceZarray_t

template<typename K >
using boardstate::ZobristCalculatorForConcepts< K >::PieceZarray_t = array<array<K, gameboard::kNumFiles>, gameboard::kNumRanks>
private

Definition at line 17 of file zobrist_calculator_for_concepts.hpp.

◆ TeamZarray_t

template<typename K >
using boardstate::ZobristCalculatorForConcepts< K >::TeamZarray_t = array<PieceZarray_t, gameboard::kNumPieceTypeVals>
private

Definition at line 18 of file zobrist_calculator_for_concepts.hpp.

Constructor & Destructor Documentation

◆ ZobristCalculatorForConcepts()

template<typename K >
boardstate::ZobristCalculatorForConcepts< K >::ZobristCalculatorForConcepts ( uint32_t  seed = std::random_device{}())
inlineprivate

Constructs a ZobristCalculatorForConcepts.

Parameters
seedInteger used as a seed for a PRNG that generates Zobrist key values.

Definition at line 52 of file zobrist_calculator_for_concepts.hpp.

Member Function Documentation

◆ board_state()

template<typename K >
KeyType boardstate::ZobristCalculatorForConcepts< K >::board_state ( ) const
inline

Definition at line 37 of file zobrist_calculator_for_concepts.hpp.

◆ Create()

template<typename K >
static std::shared_ptr< ZobristCalculatorForConcepts< K > > boardstate::ZobristCalculatorForConcepts< K >::Create ( uint32_t  seed = std::random_device{}())
inlinestatic

Definition at line 28 of file zobrist_calculator_for_concepts.hpp.

◆ CreateGameZarray()

template<typename K >
static const GameZarray_t boardstate::ZobristCalculatorForConcepts< K >::CreateGameZarray ( PseudoRandomKeyGenerator< K > &  key_generator)
inlinestaticprivate

Static helper method for building 4-D array of Zobrist keys in constuctor.

Definition at line 63 of file zobrist_calculator_for_concepts.hpp.

◆ FullBoardStateCalc()

template<typename K >
void boardstate::ZobristCalculatorForConcepts< K >::FullBoardStateCalc ( const gameboard::BoardMap_t board_map)
inline

Definition at line 41 of file zobrist_calculator_for_concepts.hpp.

◆ FullBoardStateCalcInternal()

template<typename K >
void boardstate::ZobristCalculatorForConcepts< K >::FullBoardStateCalcInternal ( const gameboard::BoardMap_t board_map)
inlineprivate

Definition at line 84 of file zobrist_calculator_for_concepts.hpp.

◆ GetHashValueAt()

template<typename K >
K boardstate::ZobristCalculatorForConcepts< K >::GetHashValueAt ( PieceColor  color,
PieceType  piece_type,
BoardSpace  space 
)
inlineprivate

Definition at line 78 of file zobrist_calculator_for_concepts.hpp.

◆ seed()

template<typename K >
uint32_t boardstate::ZobristCalculatorForConcepts< K >::seed ( ) const
inline

Definition at line 38 of file zobrist_calculator_for_concepts.hpp.

◆ UpdateBoardState()

template<typename K >
void boardstate::ZobristCalculatorForConcepts< K >::UpdateBoardState ( const gameboard::ExecutedMove executed_move)
inline

Definition at line 45 of file zobrist_calculator_for_concepts.hpp.

◆ UpdateBoardStateInternal()

template<typename K >
void boardstate::ZobristCalculatorForConcepts< K >::UpdateBoardStateInternal ( const gameboard::ExecutedMove executed_move)
inlineprivate

Definition at line 99 of file zobrist_calculator_for_concepts.hpp.

Member Data Documentation

◆ board_state_

template<typename K >
K boardstate::ZobristCalculatorForConcepts< K >::board_state_
private

Definition at line 24 of file zobrist_calculator_for_concepts.hpp.

◆ seed_

template<typename K >
uint32_t boardstate::ZobristCalculatorForConcepts< K >::seed_
private

Definition at line 23 of file zobrist_calculator_for_concepts.hpp.

◆ turn_key_

template<typename K >
K boardstate::ZobristCalculatorForConcepts< K >::turn_key_
private

Definition at line 22 of file zobrist_calculator_for_concepts.hpp.

◆ zarray_

template<typename K >
GameZarray_t boardstate::ZobristCalculatorForConcepts< K >::zarray_
private

Definition at line 21 of file zobrist_calculator_for_concepts.hpp.


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