Xiangiqgame
AI engine for Xiangqi
Loading...
Searching...
No Matches
piece_points_data_structs.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
9#include <string>
10#include <unordered_map>
11
12using namespace std;
13
14namespace piecepoints {
15
16// typedef int Points_t;
17inline size_t size_of_points_type() { return sizeof(Points_t); }
18inline bool is_signed_points_type() { return numeric_limits<Points_t>::is_signed; }
19
22typedef array<array<int, gameboard::kNumFiles>, gameboard::kNumRanks> PiecePointsArray_t;
23
24inline bool operator==(const PiecePointsArray_t &a, const PiecePointsArray_t &b) {
25 bool are_equal = true;
26
27 for (auto rank = 0; rank < gameboard::kNumRanks; rank++) {
28 for (auto file = 0; file < gameboard::kNumFiles; file++) {
29 if (a[rank][file] != b[rank][file]) {
30 are_equal = false;
31 return are_equal;
32 }
33 }
34 }
35 return are_equal;
36}
37
38// 3-D array of all piece points values for a team
39typedef array<PiecePointsArray_t, gameboard::kNumPieceTypeVals> TeamPointsArray_t;
40typedef unordered_map<gameboard::PieceType, PiecePointsArray_t> TeamPointsEMap_t;
41typedef unordered_map<string, PiecePointsArray_t> TeamPointsSMap_t;
42
43inline bool operator==(const TeamPointsSMap_t &a,const TeamPointsSMap_t &b) {
44 bool are_equal = true;
45
46 for (auto &piece : a) {
47 if (a.at(piece.first) != b.at(piece.first)) {
48 are_equal = false;
49 return are_equal;
50 }
51 }
52 return are_equal;
53}
54
55// 4-D array of both teams points values for a game
56typedef array<TeamPointsArray_t, 2> GamePointsArray_t;
57typedef unordered_map<gameboard::PieceColor, TeamPointsEMap_t> GamePointsEMap_t;
58typedef unordered_map<string, TeamPointsSMap_t> GamePointsSMap_t;
60 bool are_equal = true;
61 for (auto color : a) {
62 if (a[color.first] != b[color.first]) {
63 are_equal = false;
64 return are_equal;
65 }
66 }
67 return are_equal;
68}
69
70// types for base-points offset (BPO) spec
71typedef unordered_map<gameboard::PieceType, Points_t> TeamBasePoints_t;
72typedef unordered_map<string, Points_t> BasePointsSMap_t;
73} // namespace piecepoints
Constants, typedefs, and simple structs used by gameboard::GameBoard.
Defines GamePiece and supporting constants and free functions.
int Points_t
const BoardIndexType kNumFiles
const BoardIndexType kNumRanks
Providing position-dependent values of pieces to objects in moveselection namespace.
unordered_map< string, Points_t > BasePointsSMap_t
array< TeamPointsArray_t, 2 > GamePointsArray_t
unordered_map< string, PiecePointsArray_t > TeamPointsSMap_t
unordered_map< gameboard::PieceType, Points_t > TeamBasePoints_t
array< array< int, gameboard::kNumFiles >, gameboard::kNumRanks > PiecePointsArray_t
2-D array of points values for single piece at each position on a gameboard::GameBoard....
unordered_map< gameboard::PieceType, PiecePointsArray_t > TeamPointsEMap_t
bool operator==(const PiecePointsArray_t &a, const PiecePointsArray_t &b)
unordered_map< gameboard::PieceColor, TeamPointsEMap_t > GamePointsEMap_t
array< PiecePointsArray_t, gameboard::kNumPieceTypeVals > TeamPointsArray_t
unordered_map< string, TeamPointsSMap_t > GamePointsSMap_t