Xiangiqgame
AI engine for Xiangqi
Loading...
Searching...
No Matches
game_data_structs.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <iostream>
6#include <optional>
7#include <random>
9
10namespace game {
11enum GameState : int { kUnfinished = 0, kDraw = 1, kRedWon = 2, kBlkWon = 3 };
12
13enum EvaluatorType : int { kRandom = 0, kMinimax = 1, kHuman };
14enum ZobristKeyType : int { kNoKey = 0, k032BitKey = 1, k064BitKey = 2, k128BitKey = 3 };
15
17
21
25 )
28
29 bool operator==(const MinimaxTypeInfo &other) const {
30 return zobrist_key_type == other.zobrist_key_type &&
32 }
33};
34
36 std::size_t operator()(const MinimaxTypeInfo &key) const {
37 std::size_t h1 = std::hash<int>{}(key.zobrist_key_type);
38 std::size_t h2 = std::hash<int>{}(key.zobrist_calculator_count);
39 // Combine the two hash values
40 return h1 ^ (h2 << 1); // XOR and shift
41 }
42};
43
44struct PlayerSpec {
50 uint32_t zkeys_seed;
51
55 size_t zobrist_key_size_bits = 64,
56 size_t zobrist_calculator_count = 2,
58 uint32_t zkeys_seed = std::random_device{}()
59 )
60 : color{color}
66};
67
68struct GameStatus {
70 const std::vector<gameboard::ExecutedMove> &move_log;
74};
75
77 std::string game_id;
79 std::vector<ExecutedMove> move_log;
80 std::unordered_map<gameboard::PieceColor, PlayerSpec> player_specs;
81 std::unordered_map<gameboard::PieceColor, moveselection::SearchSummaries>
83 };
84
85} // namespace game
Data structs used by moveselection::MinimaxEvaluator.
uint16_t DepthType
Definitions and implementations of gameboard::Move and other move-related structs.
Definition: game.hpp:19
array< array< GamePiece, kNumFiles >, kNumRanks > BoardMap_t
2-D array of gameboard::GamePiece objects.
const gameboard::BoardMap_t & board_map
const std::vector< gameboard::ExecutedMove > & move_log
game::GameState game_state
gameboard::PieceColor whose_turn
std::unordered_map< gameboard::PieceColor, moveselection::SearchSummaries > search_summaries
game::GameState game_state
std::vector< ExecutedMove > move_log
std::unordered_map< gameboard::PieceColor, PlayerSpec > player_specs
std::size_t operator()(const MinimaxTypeInfo &key) const
bool operator==(const MinimaxTypeInfo &other) const
ZobristKeyType zobrist_key_type
ZobristCalculatorCount zobrist_calculator_count
MinimaxTypeInfo(ZobristKeyType zobrist_key_type=ZobristKeyType::kNoKey, ZobristCalculatorCount zobrist_calculator_count=ZobristCalculatorCount::kNoZCalcs)
EvaluatorType evaluator_type
PlayerSpec(gameboard::PieceColor color, EvaluatorType evaluator_type=EvaluatorType::kMinimax, size_t zobrist_key_size_bits=64, size_t zobrist_calculator_count=2, DepthType minimax_search_depth=4, uint32_t zkeys_seed=std::random_device{}())
DepthType minimax_search_depth
gameboard::PieceColor color