Xiangiqgame
AI engine for Xiangqi
|
Tracking piece positions and determining legal moves. More...
Classes | |
struct | BoardDirection |
Descirbes a direction on a gameboard::GameBoard.board_map_. More... | |
struct | BoardSpace |
A pair of coordinate (rank, and file) with properties determined by comparison with values of gameboard features: board size, river locations, and castle locations. More... | |
struct | CastleEdges |
Defines a castle feature in terms of its min / max rank and file. More... | |
struct | ExecutedMove |
A change in the state of a gameboard::GameBoard represented by a gameboard::Move, and each of the gameboard::GamePiece objects located at the start and end locations of the Move. More... | |
class | GameBoard |
Implements SpaceInfoProvider interface; stores piece positions, and exposes methods for calculating, executing, an un-doing moves. More... | |
class | GameBoardFactory |
class | GameBoardForConcepts |
Must comply with SpaceInfoProviderConcept; stores piece positions, and exposes methods for calculating, executing, an un-doing moves. More... | |
struct | GamePiece |
A Xiangqi game piece described by its gameboard::PieceType and its gameboard::PieceColor. More... | |
struct | Move |
A gameboard::BoardSpace pair (start and end). More... | |
class | MoveCalculator |
Calculates legal gameboard::Move objects for of a gameboard::GameBoard with a particular state. More... | |
struct | MoveCollection |
A container for multiple gameboard::Move objects. More... | |
class | PieceMoves |
Implements piece type dependent move rules; used by gameboard::MoveCalculator. More... | |
Typedefs | |
typedef array< array< GamePiece, kNumFiles >, kNumRanks > | BoardMap_t |
2-D array of gameboard::GamePiece objects. | |
typedef array< array< int, kNumFiles >, kNumRanks > | BoardMapInt_t |
2-D array of integers; can be converted to gameboard::BoardMap_t using gameboard::int_board_to_game_pieces. | |
typedef array< BoardSpace, 9 > | Castle_t |
typedef void(PieceMoves::* | MethodPtr_t) (const BoardMap_t &, PieceColor, const BoardSpace &, MoveCollection &) |
typedef array< MethodPtr_t, kNumPieceTypeVals > | PieceDispatchArray_t |
Enumerations | |
enum | PieceType : int { kNnn = 0 , kGen = 1 , kAdv = 2 , kEle = 3 , kHor = 4 , kCha = 5 , kCan = 6 , kSol = 7 } |
enum | PieceColor : int { kRed = -1 , kNul = 0 , kBlk = 1 } |
Functions | |
PieceColor | opponent_of (PieceColor color) |
constexpr Castle_t | calc_castle_spaces (const CastleEdges &edges) |
constexpr Castle_t | red_castle_spaces () |
constexpr Castle_t | black_castle_spaces () |
BoardMap_t | int_board_to_game_pieces (const BoardMapInt_t int_board) |
bool | is_occupied (const BoardMap_t &board_map, const BoardSpace &space) |
PieceColor | get_color (const BoardMap_t &board_map, const BoardSpace &space) |
PieceType | get_type (const BoardMap_t &board_map, const BoardSpace &space) |
BoardSpace | get_general_position (const BoardMap_t &board_map, const PieceColor color) |
vector< BoardSpace > | get_all_spaces_occupied_by (const BoardMap_t &board_map, const PieceColor color) |
size_t | GetZColorIndexOf (PieceColor color) |
PieceColor | GetPieceColorOf (size_t zcolor_index) |
constexpr PieceDispatchArray_t | build_piece_dispatch_array () |
Variables | |
const BoardIndexType | kNumRanks = 10 |
const BoardIndexType | kNumFiles = 9 |
const BoardIndexType | kRedRiverEdge = 5 |
const BoardIndexType | kBlackRiverEdge = 4 |
constexpr CastleEdges | kRedCastleEdges = {7, 9, 3, 5} |
constexpr CastleEdges | kBlackCastleEdges = {0, 2, 3, 5} |
const BoardMapInt_t | kStandardInitialBoard |
Starting board represented as 2-D array of integers. | |
const int | kRepeatPeriodsToCheck [3] = {2, 3, 4} |
Max allowed repetitions of prohibited move sequence lengths. | |
const int | kRepeatPeriodsMaxAllowed = 2 |
Repeated move sequence lengths forbidden under move repetition rules. | |
const int | kMaxMovesWithoutCapture = 120 |
const int | kNumPieceTypeVals = 8 |
const unordered_map< string, PieceType > | kPieceTypeStringToEnum |
const int | kNumPieceColorVals = 3 |
const unordered_map< string, PieceColor > | kPieceColorStringToEnum |
const array< BoardDirection, 2 > | kSideDirections |
const vector< pair< BoardDirection, vector< BoardDirection > > > | kHorsePaths |
const vector< BoardDirection > | kAllOrthogonalDirections |
const vector< BoardDirection > | kAllDiagonalDirections |
Tracking piece positions and determining legal moves.
typedef array<array<GamePiece, kNumFiles>, kNumRanks> gameboard::BoardMap_t |
2-D array of gameboard::GamePiece objects.
This is the data type of gameboard::GameBoard.board_map_.
Definition at line 44 of file board_data_structs.hpp.
typedef array<array<int, kNumFiles>, kNumRanks> gameboard::BoardMapInt_t |
2-D array of integers; can be converted to gameboard::BoardMap_t using gameboard::int_board_to_game_pieces.
Definition at line 47 of file board_data_structs.hpp.
typedef array<BoardSpace, 9> gameboard::Castle_t |
Definition at line 89 of file board_data_structs.hpp.
typedef void(PieceMoves::* gameboard::MethodPtr_t) (const BoardMap_t &, PieceColor, const BoardSpace &, MoveCollection &) |
Definition at line 16 of file move_calculator_details.hpp.
typedef array<MethodPtr_t, kNumPieceTypeVals> gameboard::PieceDispatchArray_t |
Definition at line 19 of file move_calculator_details.hpp.
enum gameboard::PieceColor : int |
Enumerator | |
---|---|
kRed | |
kNul | |
kBlk |
Definition at line 38 of file game_piece.hpp.
enum gameboard::PieceType : int |
Enumerator | |
---|---|
kNnn | |
kGen | |
kAdv | |
kEle | |
kHor | |
kCha | |
kCan | |
kSol |
Definition at line 13 of file game_piece.hpp.
|
constexpr |
Definition at line 106 of file board_data_structs.hpp.
|
inlineconstexpr |
Definition at line 21 of file move_calculator_details.hpp.
|
inlineconstexpr |
Definition at line 92 of file board_data_structs.hpp.
|
inline |
Definition at line 150 of file board_data_structs.hpp.
|
inline |
Definition at line 124 of file board_data_structs.hpp.
|
inline |
Definition at line 132 of file board_data_structs.hpp.
|
inline |
Definition at line 128 of file board_data_structs.hpp.
|
inline |
Definition at line 81 of file game_piece.hpp.
|
inline |
Definition at line 77 of file game_piece.hpp.
|
inline |
Definition at line 110 of file board_data_structs.hpp.
|
inline |
Definition at line 120 of file board_data_structs.hpp.
|
inline |
Definition at line 38 of file board_data_structs.hpp.
|
constexpr |
Definition at line 104 of file board_data_structs.hpp.
const vector< BoardDirection > gameboard::kAllDiagonalDirections |
Definition at line 27 of file piece_moves.cpp.
const vector< BoardDirection > gameboard::kAllOrthogonalDirections |
Definition at line 20 of file piece_moves.cpp.
|
constexpr |
Definition at line 31 of file board_data_structs.hpp.
const BoardIndexType gameboard::kBlackRiverEdge = 4 |
Definition at line 21 of file board_data_structs.hpp.
const vector< pair< BoardDirection, vector< BoardDirection > > > gameboard::kHorsePaths |
Definition at line 13 of file piece_moves.cpp.
const int gameboard::kMaxMovesWithoutCapture = 120 |
Definition at line 17 of file game_board_for_concepts.hpp.
const BoardIndexType gameboard::kNumFiles = 9 |
Definition at line 18 of file board_data_structs.hpp.
const int gameboard::kNumPieceColorVals = 3 |
Definition at line 39 of file game_piece.hpp.
const int gameboard::kNumPieceTypeVals = 8 |
Definition at line 23 of file game_piece.hpp.
const BoardIndexType gameboard::kNumRanks = 10 |
Definition at line 17 of file board_data_structs.hpp.
const unordered_map<string, PieceColor> gameboard::kPieceColorStringToEnum |
Definition at line 68 of file game_piece.hpp.
const unordered_map<string, PieceType> gameboard::kPieceTypeStringToEnum |
Definition at line 25 of file game_piece.hpp.
|
constexpr |
Definition at line 30 of file board_data_structs.hpp.
const BoardIndexType gameboard::kRedRiverEdge = 5 |
Definition at line 20 of file board_data_structs.hpp.
const int gameboard::kRepeatPeriodsMaxAllowed = 2 |
Repeated move sequence lengths forbidden under move repetition rules.
If kRepeatPeriodsToCheck = {2, 3, 4} and kRepeatPeriodsMaxAllowed = 2, then the following sequences are probibited: ABABAB, ABCABCABC, ABCDABCDABCD, ABCDEABCDEABCDE, ABCDEFABCDEFABCDEF
Definition at line 16 of file game_board_for_concepts.hpp.
const int gameboard::kRepeatPeriodsToCheck = {2, 3, 4} |
Max allowed repetitions of prohibited move sequence lengths.
Definition at line 15 of file game_board_for_concepts.hpp.
const array< BoardDirection, 2 > gameboard::kSideDirections |
Definition at line 8 of file piece_moves.cpp.
const BoardMapInt_t gameboard::kStandardInitialBoard |
Starting board represented as 2-D array of integers.
Can be converted to array of GamePiece objects by board_utilities::int_board_to_game_pieces.
Definition at line 14 of file game_board_for_concepts.hpp.