26 std::map<PieceColor, std::vector<ExecutedMove>>
move_log_;
30 static std::shared_ptr<GameBoardForConcepts>
Create(
39 inline const std::map<PieceColor, std::vector<ExecutedMove>> &
move_log()
const {
97 return validated_moves;
102 validated_moves.
moves.reserve(un_tested_moves.moves.size());
104 for (
auto move : un_tested_moves.moves) {
106 auto resulting_opponent_moves =
110 if (not resulting_opponent_moves.ContainsDestination(resulting_gen_position) and
112 validated_moves.Append(move);
117 return validated_moves;
122 auto opponent_moves =
143 return executed_move;
148 vector<BoardSpace> occupied_spaces;
149 occupied_spaces.reserve(16);
150 for (
auto rank = 0; rank <
kNumRanks; rank++) {
151 for (
auto file = 0; file <
kNumFiles; file++) {
153 occupied_spaces.emplace_back(
BoardSpace{rank, file});
157 return occupied_spaces;
171 callback(executed_move);
181 move_log_[piece_color].push_back(executed_move);
186 auto last_move_by_color =
move_log_[piece_color].back();
187 if (!(executed_move == last_move_by_color)) {
188 throw runtime_error(
"Last move in log does not match move to be removed");
210 std::shared_ptr<GameBoardForConcepts>
Create(
Constants, typedefs, and simple structs used by gameboard::GameBoard.
std::shared_ptr< GameBoardForConcepts > Create(const BoardMapInt_t &starting_board=kStandardInitialBoard)
Must comply with SpaceInfoProviderConcept; stores piece positions, and exposes methods for calculatin...
const BoardMap_t & map() const
MoveCalculator move_calculator_
MoveCollection CalcFinalMovesOf(PieceColor color)
ExecutedMove ExecuteMove(const Move &move)
GamePiece GetOccupantAt(const BoardSpace &space) const
std::vector< BoardSpace > GetAllSpacesOccupiedBy(const PieceColor color) const
std::map< PieceColor, std::vector< ExecutedMove > > move_log_
PieceColor GetColor(const BoardSpace &space) const
MoveCollection CalcFinalMovesOfInternal(PieceColor color)
MoveCountType moves_since_last_capture_
void AddToMoveLog(const ExecutedMove &executed_move)
GameBoardForConcepts(const BoardMapInt_t starting_board)
Initializes a gameboard::GameBoard from array of pieces represented as integers.
std::vector< BoardSpace > GetAllSpacesOccupiedByInternal(const PieceColor color) const
void SetOccupantAt(const BoardSpace &space, GamePiece piece)
void UpdateStateTracker(const ExecutedMove &executed_move)
bool ViolatesRepeatRule(PieceColor color)
bool IsInCheckInternal(PieceColor color)
ExecutedMove ExecuteMoveInternal(const Move &move)
void AttachMoveCallback(const function< void(const ExecutedMove &)> &callback)
bool IsInCheck(PieceColor color)
vector< function< void(const ExecutedMove &)> > move_callbacks_
void RemoveFromMoveLog(const ExecutedMove &executed_move)
PieceType GetType(const BoardSpace &space) const
const std::map< PieceColor, std::vector< ExecutedMove > > & move_log() const
void UndoMove(const ExecutedMove &executed_move)
void UndoMoveInternal(const ExecutedMove &executed_move)
bool IsCaptureMove(const ExecutedMove &executed_move) const
static std::shared_ptr< GameBoardForConcepts > Create(const BoardMapInt_t &starting_board=kStandardInitialBoard)
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::MoveCalculator.
Definitions and implementations of gameboard::Move and other move-related structs.
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...
const BoardIndexType kNumFiles
const BoardIndexType kNumRanks
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.
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.
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