Xiangiqgame
AI engine for Xiangqi
Loading...
Searching...
No Matches
piece_position_points_for_concepts.cpp
Go to the documentation of this file.
3#include <unordered_map>
5
6namespace piecepoints {
7
8// PiecePositionPointsForConcepts::PiecePositionPointsForConcepts()
9// : points_array{BPOPointsSKeys(kICGABPOPath).ToGamePointsArray()} {}
10
12 GamePointsArray_t &game_points_array
13)
14 : points_array{game_points_array} {}
15
16std::shared_ptr<PiecePositionPointsForConcepts> PiecePositionPointsForConcepts::Create(
17 std::string json_file
18) {
19 piecepoints::BPOPointsSKeys bpo_points_skeys{json_file};
20 auto game_points_array = bpo_points_skeys.ToGamePointsArray();
21 return std::shared_ptr<PiecePositionPointsForConcepts>(
22 new PiecePositionPointsForConcepts(game_points_array)
23 );
24}
25
27 TeamPointsArray_t team_array
28) {
29 TeamPointsEMap_t team_map;
30 for (auto piece_idx = 0; piece_idx < gameboard::kNumPieceTypeVals; piece_idx++) {
31 team_map[static_cast<gameboard::PieceType>(piece_idx)] = team_array[piece_idx];
32 }
33 return team_map;
34}
35
37 GamePointsEMap_t pts_map;
38 for (auto zcolor_idx = 0; zcolor_idx < points_array.size(); zcolor_idx++) {
39 pts_map[gameboard::GetPieceColorOf(zcolor_idx)] =
41 }
42 return pts_map;
43}
44
46 auto e_map = PointsArrayToEMap();
47 GamePointsSMap_t game_string_map;
48
49 for (auto color : gameboard::kPieceColorStringToEnum) {
50 if (e_map.contains(color.second)) {
51 game_string_map[color.first] = utility_functs::replace_keys_reverse(
52 e_map[color.second],
54 );
55 }
56 }
57 return game_string_map;
58}
59
60} // namespace piecepoints
Definitions of classes used for storing piece points in Base Points Offset form.
Piece Points spec in "Base Points Offset" form with string keys in member unordered_map objects for e...
GamePointsArray_t ToGamePointsArray()
PieceColor GetPieceColorOf(size_t zcolor_index)
Definition: game_piece.hpp:81
const unordered_map< string, PieceType > kPieceTypeStringToEnum
Definition: game_piece.hpp:25
const int kNumPieceTypeVals
Definition: game_piece.hpp:23
const unordered_map< string, PieceColor > kPieceColorStringToEnum
Definition: game_piece.hpp:68
Providing position-dependent values of pieces to objects in moveselection namespace.
array< TeamPointsArray_t, 2 > GamePointsArray_t
unordered_map< gameboard::PieceType, PiecePointsArray_t > TeamPointsEMap_t
unordered_map< gameboard::PieceColor, TeamPointsEMap_t > GamePointsEMap_t
array< PiecePointsArray_t, gameboard::kNumPieceTypeVals > TeamPointsArray_t
unordered_map< string, TeamPointsSMap_t > GamePointsSMap_t
unordered_map< ToKey, Value > replace_keys_reverse(unordered_map< FromKey, Value > orig_map, unordered_map< ToKey, FromKey > key_substitutions)
Holds a piecepoints::GamePointsArray_t of points values, and exposes a method for accessing element c...
static std::shared_ptr< PiecePositionPointsForConcepts > Create(std::string json_file=piecepoints::kICGABPOPath)
static TeamPointsEMap_t TeamPointsArrayToEMap(TeamPointsArray_t team_array)
PiecePositionPointsForConcepts(GamePointsArray_t &game_points_array)
Defiition of miscellaneous free functions (and implementation of those that are templates).