19 {5, 4, 3, 2, 1, 2, 3, 4, 5},
20 {0, 0, 0, 0, 0, 0, 0, 0, 0},
21 {0, 6, 0, 0, 0, 0, 0, 6, 0},
22 {7, 0, 7, 0, 7, 0, 7, 0, 7},
23 {0, 0, 0, 0, 0, 0, 0, 0, 0},
24 {0, 0, 0, 0, 0, 0, 0, 0, 0},
25 {-7, 0, -7, 0, -7, 0, -7, 0, -7},
26 {0, -6, 0, 0, 0, 0, 0, -6, 0},
27 {0, 0, 0, 0, 0, 0, 0, 0, 0},
28 {-5, -4, -3, -2, -1, -2, -3, -4, -5},
47 , moves_since_last_capture_{} {}
69 return validated_moves;
72 validated_moves.
moves.reserve(un_tested_moves.moves.size());
74 for (
auto move : un_tested_moves.moves) {
76 auto resulting_opponent_moves =
80 if (not resulting_opponent_moves.ContainsDestination(resulting_gen_position) and
82 validated_moves.Append(move);
87 return validated_moves;
113 return executed_move;
149 callback(executed_move);
159 move_log_[piece_color].push_back(executed_move);
164 auto last_move_by_color =
move_log_[piece_color].back();
165 if (!(executed_move == last_move_by_color)) {
166 throw runtime_error(
"Last move in log does not match move to be removed");
Constants, typedefs, and simple structs used by gameboard::GameBoard.
Implements SpaceInfoProvider interface; stores piece positions, and exposes methods for calculating,...
bool ViolatesRepeatRule(PieceColor color)
vector< BoardSpace > ImplementGetAllSpacesOccupiedBy(PieceColor color) const
MoveCalculator move_calculator_
Encapsulates all calculations of allowed moves.
void AddToMoveLog(const ExecutedMove &executed_move)
void ImplementAttachMoveCallback(const function< void(const ExecutedMove &)> &callback)
MoveCollection ImplementCalcFinalMovesOf(PieceColor color)
void UpdateStateTracker(const ExecutedMove &executed_move)
std::map< PieceColor, vector< ExecutedMove > > move_log_
Vectors of all moves that have been executed (and not un-done) by each player.
const std::map< PieceColor, vector< ExecutedMove > > & move_log() const
vector< function< void(const ExecutedMove &)> > move_callbacks_
Stores functions that are called after any change in board config to keep boardstate::SingleZobristCo...
bool IsInCheck(PieceColor color)
PieceType ImplementGetType(const BoardSpace &space) const
void RemoveFromMoveLog(const ExecutedMove &executed_move)
ExecutedMove ImplementExecuteMove(const Move &move)
MoveCountType moves_since_last_capture_
Number of moves executed since last time a piece was captured.
bool IsCaptureMove(const ExecutedMove &executed_move) const
GamePiece GetOccupantAt(const BoardSpace &space) const
BoardMap_t board_map_
2-D array of GamePiece objects.
PieceColor ImplementGetColor(const BoardSpace &space) const
void SetOccupantAt(const BoardSpace &space, GamePiece piece)
const BoardMap_t & map() const
void ImplementUndoMove(const ExecutedMove &executed_move)
Calculates legal gameboard::Move objects for of a gameboard::GameBoard with a particular state.
MoveCollection CalcAllMovesNoCheckTest(PieceColor color, const BoardMap_t &board_map)
Definition of gameboard::GameBoard class.
Tracking piece positions and determining legal moves.
const BoardMapInt_t kStandardInitialBoard
Starting board represented as 2-D array of integers.
BoardSpace get_general_position(const BoardMap_t &board_map, const PieceColor color)
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_p...
vector< BoardSpace > get_all_spaces_occupied_by(const BoardMap_t &board_map, const PieceColor color)
PieceColor opponent_of(PieceColor color)
BoardMap_t int_board_to_game_pieces(const BoardMapInt_t int_board)
array< array< GamePiece, kNumFiles >, kNumRanks > BoardMap_t
2-D array of gameboard::GamePiece objects.
PieceColor get_color(const BoardMap_t &board_map, const BoardSpace &space)
const int kRepeatPeriodsToCheck[3]
Max allowed repetitions of prohibited move sequence lengths.
const int kMaxMovesWithoutCapture
const int kRepeatPeriodsMaxAllowed
Repeated move sequence lengths forbidden under move repetition rules.
PieceType get_type(const BoardMap_t &board_map, const BoardSpace &space)
bool hasRepeatingPattern(const std::vector< T > &vec, int lookback_length, int period)
A pair of coordinate (rank, and file) with properties determined by comparison with values of gameboa...
A change in the state of a gameboard::GameBoard represented by a gameboard::Move, and each of the gam...
gameboard::GamePiece moving_piece
MoveCountType moves_since_last_capture
gameboard::GamePiece destination_piece
A Xiangqi game piece described by its gameboard::PieceType and its gameboard::PieceColor.
A container for multiple gameboard::Move objects.
bool ContainsDestination(const gameboard::BoardSpace &space)
A gameboard::BoardSpace pair (start and end).
gameboard::BoardSpace end
gameboard::BoardSpace start
Defiition of miscellaneous free functions (and implementation of those that are templates).