Xiangiqgame
AI engine for Xiangqi
Loading...
Searching...
No Matches
gameboard::GameBoardForConcepts Class Reference

Must comply with SpaceInfoProviderConcept; stores piece positions, and exposes methods for calculating, executing, an un-doing moves. More...

#include <game_board_for_concepts.hpp>

Inheritance diagram for gameboard::GameBoardForConcepts:
Inheritance graph
Collaboration diagram for gameboard::GameBoardForConcepts:
Collaboration graph

Public Member Functions

const BoardMap_tmap () const
 
const std::map< PieceColor, std::vector< ExecutedMove > > & move_log () const
 
void AttachMoveCallback (const function< void(const ExecutedMove &)> &callback)
 
PieceColor GetColor (const BoardSpace &space) const
 
bool IsInCheck (PieceColor color)
 
ExecutedMove ExecuteMove (const Move &move)
 
bool IsDraw ()
 
std::vector< BoardSpaceGetAllSpacesOccupiedBy (const PieceColor color) const
 
PieceType GetType (const BoardSpace &space) const
 
MoveCollection CalcFinalMovesOf (PieceColor color)
 
bool IsCaptureMove (const ExecutedMove &executed_move) const
 
void UndoMove (const ExecutedMove &executed_move)
 
GamePiece GetOccupantAt (const BoardSpace &space) const
 
- Public Member Functions inherited from SpaceInfoProviderBase
virtual ~SpaceInfoProviderBase ()=default
 
virtual const gameboard::BoardMap_tmap () const =0
 
virtual bool IsDraw ()=0
 
virtual bool IsInCheck (gameboard::PieceColor)=0
 
virtual gameboard::MoveCollection CalcFinalMovesOf (gameboard::PieceColor)=0
 
virtual gameboard::ExecutedMove ExecuteMove (const Move &move)=0
 

Static Public Member Functions

static std::shared_ptr< GameBoardForConceptsCreate (const BoardMapInt_t &starting_board=kStandardInitialBoard)
 

Private Member Functions

 GameBoardForConcepts (const BoardMapInt_t starting_board)
 Initializes a gameboard::GameBoard from array of pieces represented as integers.
 
MoveCollection CalcFinalMovesOfInternal (PieceColor color)
 
bool IsInCheckInternal (PieceColor color)
 
ExecutedMove ExecuteMoveInternal (const Move &move)
 
std::vector< BoardSpaceGetAllSpacesOccupiedByInternal (const PieceColor color) const
 
void UndoMoveInternal (const ExecutedMove &executed_move)
 
void UpdateStateTracker (const ExecutedMove &executed_move)
 
void SetOccupantAt (const BoardSpace &space, GamePiece piece)
 
void AddToMoveLog (const ExecutedMove &executed_move)
 
void RemoveFromMoveLog (const ExecutedMove &executed_move)
 
bool ViolatesRepeatRule (PieceColor color)
 

Private Attributes

BoardMap_t board_map_
 
MoveCalculator move_calculator_
 
vector< function< void(const ExecutedMove &)> > move_callbacks_
 
std::map< PieceColor, std::vector< ExecutedMove > > move_log_
 
MoveCountType moves_since_last_capture_
 

Detailed Description

Must comply with SpaceInfoProviderConcept; stores piece positions, and exposes methods for calculating, executing, an un-doing moves.

Definition at line 22 of file game_board_for_concepts.hpp.

Constructor & Destructor Documentation

◆ GameBoardForConcepts()

gameboard::GameBoardForConcepts::GameBoardForConcepts ( const BoardMapInt_t  starting_board)
inlineprivate

Initializes a gameboard::GameBoard from array of pieces represented as integers.

Parameters
starting_boardAn array of integers representing pieces on the board.

Definition at line 84 of file game_board_for_concepts.hpp.

Member Function Documentation

◆ AddToMoveLog()

void gameboard::GameBoardForConcepts::AddToMoveLog ( const ExecutedMove executed_move)
inlineprivate

Definition at line 179 of file game_board_for_concepts.hpp.

◆ AttachMoveCallback()

void gameboard::GameBoardForConcepts::AttachMoveCallback ( const function< void(const ExecutedMove &)> &  callback)
inline

Definition at line 43 of file game_board_for_concepts.hpp.

◆ CalcFinalMovesOf()

MoveCollection gameboard::GameBoardForConcepts::CalcFinalMovesOf ( PieceColor  color)
inlinevirtual

Implements SpaceInfoProviderBase.

Definition at line 65 of file game_board_for_concepts.hpp.

◆ CalcFinalMovesOfInternal()

MoveCollection gameboard::GameBoardForConcepts::CalcFinalMovesOfInternal ( PieceColor  color)
inlineprivate

Definition at line 90 of file game_board_for_concepts.hpp.

◆ Create()

static std::shared_ptr< GameBoardForConcepts > gameboard::GameBoardForConcepts::Create ( const BoardMapInt_t starting_board = kStandardInitialBoard)
inlinestatic

Definition at line 30 of file game_board_for_concepts.hpp.

◆ ExecuteMove()

ExecutedMove gameboard::GameBoardForConcepts::ExecuteMove ( const Move move)
inlinevirtual

Implements SpaceInfoProviderBase.

Definition at line 53 of file game_board_for_concepts.hpp.

◆ ExecuteMoveInternal()

ExecutedMove gameboard::GameBoardForConcepts::ExecuteMoveInternal ( const Move move)
inlineprivate

Definition at line 127 of file game_board_for_concepts.hpp.

◆ GetAllSpacesOccupiedBy()

std::vector< BoardSpace > gameboard::GameBoardForConcepts::GetAllSpacesOccupiedBy ( const PieceColor  color) const
inline

Definition at line 57 of file game_board_for_concepts.hpp.

◆ GetAllSpacesOccupiedByInternal()

std::vector< BoardSpace > gameboard::GameBoardForConcepts::GetAllSpacesOccupiedByInternal ( const PieceColor  color) const
inlineprivate

Definition at line 146 of file game_board_for_concepts.hpp.

◆ GetColor()

PieceColor gameboard::GameBoardForConcepts::GetColor ( const BoardSpace space) const
inline

Definition at line 47 of file game_board_for_concepts.hpp.

◆ GetOccupantAt()

GamePiece gameboard::GameBoardForConcepts::GetOccupantAt ( const BoardSpace space) const
inline

Definition at line 77 of file game_board_for_concepts.hpp.

◆ GetType()

PieceType gameboard::GameBoardForConcepts::GetType ( const BoardSpace space) const
inline

Definition at line 61 of file game_board_for_concepts.hpp.

◆ IsCaptureMove()

bool gameboard::GameBoardForConcepts::IsCaptureMove ( const ExecutedMove executed_move) const
inline

Definition at line 69 of file game_board_for_concepts.hpp.

◆ IsDraw()

bool gameboard::GameBoardForConcepts::IsDraw ( )
inlinevirtual

Implements SpaceInfoProviderBase.

Definition at line 55 of file game_board_for_concepts.hpp.

◆ IsInCheck()

bool gameboard::GameBoardForConcepts::IsInCheck ( PieceColor  color)
inlinevirtual

Implements SpaceInfoProviderBase.

Definition at line 51 of file game_board_for_concepts.hpp.

◆ IsInCheckInternal()

bool gameboard::GameBoardForConcepts::IsInCheckInternal ( PieceColor  color)
inlineprivate

Definition at line 120 of file game_board_for_concepts.hpp.

◆ map()

const BoardMap_t & gameboard::GameBoardForConcepts::map ( ) const
inlinevirtual

Implements SpaceInfoProviderBase.

Definition at line 37 of file game_board_for_concepts.hpp.

◆ move_log()

const std::map< PieceColor, std::vector< ExecutedMove > > & gameboard::GameBoardForConcepts::move_log ( ) const
inline

Definition at line 39 of file game_board_for_concepts.hpp.

◆ RemoveFromMoveLog()

void gameboard::GameBoardForConcepts::RemoveFromMoveLog ( const ExecutedMove executed_move)
inlineprivate

Definition at line 184 of file game_board_for_concepts.hpp.

◆ SetOccupantAt()

void gameboard::GameBoardForConcepts::SetOccupantAt ( const BoardSpace space,
GamePiece  piece 
)
inlineprivate

Definition at line 175 of file game_board_for_concepts.hpp.

◆ UndoMove()

void gameboard::GameBoardForConcepts::UndoMove ( const ExecutedMove executed_move)
inline

Definition at line 73 of file game_board_for_concepts.hpp.

◆ UndoMoveInternal()

void gameboard::GameBoardForConcepts::UndoMoveInternal ( const ExecutedMove executed_move)
inlineprivate

Definition at line 160 of file game_board_for_concepts.hpp.

◆ UpdateStateTracker()

void gameboard::GameBoardForConcepts::UpdateStateTracker ( const ExecutedMove executed_move)
inlineprivate

Definition at line 168 of file game_board_for_concepts.hpp.

◆ ViolatesRepeatRule()

bool gameboard::GameBoardForConcepts::ViolatesRepeatRule ( PieceColor  color)
inlineprivate

Definition at line 193 of file game_board_for_concepts.hpp.

Member Data Documentation

◆ board_map_

BoardMap_t gameboard::GameBoardForConcepts::board_map_
private

Definition at line 23 of file game_board_for_concepts.hpp.

◆ move_calculator_

MoveCalculator gameboard::GameBoardForConcepts::move_calculator_
private

Definition at line 24 of file game_board_for_concepts.hpp.

◆ move_callbacks_

vector<function<void(const ExecutedMove &)> > gameboard::GameBoardForConcepts::move_callbacks_
private

Definition at line 25 of file game_board_for_concepts.hpp.

◆ move_log_

std::map<PieceColor, std::vector<ExecutedMove> > gameboard::GameBoardForConcepts::move_log_
private

Definition at line 26 of file game_board_for_concepts.hpp.

◆ moves_since_last_capture_

MoveCountType gameboard::GameBoardForConcepts::moves_since_last_capture_
private

Definition at line 27 of file game_board_for_concepts.hpp.


The documentation for this class was generated from the following file: