Belofte version 2.1.9
A promising chess program using the UCI or Winboard interface
bBoard Class Reference

board More...

#include <board.h>

+ Inheritance diagram for bBoard:
+ Collaboration diagram for bBoard:

Public Member Functions

 bBoard (bBoard const &b)
 Copy board with limited board data, no board history.
 
 bBoard (bBoard const &b, bMove &m)
 Create copy of board with limited board data and history.
 
 bBoard (bFen const &fen)
 used by setFENInitialPos
 
 ~bBoard () override
 
bBoardoperator= (bBoard const &b)=delete
 
bBoardoperator= (bBoard &&b)=delete
 
void invertColours ()
 invert colours update kingpos, update colour to move, castle rights, ...
 
constexpr bGameStage getGameStage () const
 
void clearGameStage ()
 
std::string getGameStageName () const
 
void calcGameStage ()
 calculate stage of game to assist in evaluation
 
constexpr bool needCalcMinorPieces () const
 
constexpr bool noNeedCalcMinorPieces () const
 
void setNeedCalcMinorPieces ()
 
void clearNeedCalcMinorPieces ()
 
void calcMinorPieces (bool const bForceRecalc=false)
 Recalculate minor pieces, used for evaluation and end of game condition in case of less than 5 pieces.
 
constexpr bmove_t getMove () const
 
void clearMove ()
 
void setMove (bmove_t const bmt)
 
movesequence_t const & getPreviousMoves () const
 
void setPreviousMoves (movesequence_t const &v)
 
movesequence_t const & getVariation () const
 
void clearVariation ()
 
void setVariation (bBoard const &chldbrd)
 
boardInfo_t applyMove (bMove const &m) override
 modification of board move is kept on previous board newboard does not have move stored and has flag to recalculate minor pieces
 
 operator std::string () const
 print board
 
- Public Member Functions inherited from bBasicBoard
 bBasicBoard (bBasicBoard const &bb)
 
virtual ~bBasicBoard ()
 
constexpr plynum_t getPly () const
 
void setPly (plynum_t const p)
 
void incPly ()
 
void decPly ()
 
constexpr bool isEpSet () const
 
constexpr case_t getEp () const
 
constexpr column_t getEpColumn () const
 
void setEp (case_t const e)
 set ep case, it will actually be stored as column only rank will be calculated based on side to move function is never called to clear ep case or when ep is not set
 
void clearEp ()
 
constexpr movenum50_t getPly50Moves () const
 
void setPly50Moves (movenum50_t const p)
 
void incPly50Moves ()
 
void clearPly50Moves ()
 
constexpr bool hasCastleRights (uint8_t const f) const
 
void setWhiteHasCastled ()
 
void setBlackHasCastled ()
 
void clearWhiteHasCastled ()
 
void clearBlackHasCastled ()
 
constexpr bool whiteHasCastled () const
 
constexpr bool blackHasCastled () const
 
void setCastleRights (uint8_t const f)
 
void setCastleRights (uint8_t const f, bool const c)
 
void clearCastleRights (uint8_t const f)
 
constexpr bool isInCheck () const
 
void setInCheck ()
 
void clearInCheck ()
 
constexpr bool isNonSilent () const
 
void setNonSilent ()
 
void clearNonSilent ()
 
constexpr piece_t getCapturedPiece () const
 
void setCapturedPiece (piece_t p)
 
void clearCapturedPiece ()
 
constexpr bool whiteToMove () const
 
constexpr bool blackToMove () const
 
constexpr int16_t getMoveNumber () const
 
constexpr side_t getColourToMove () const
 
constexpr bScore minimizing () const
 
constexpr piece_t getPiece (case_t const cf) const
 
constexpr piece_t getPiece (column_t const iColumn, rank_t const iRank) const
 
piece_t getPieceCtl (column_t const iColumn, rank_t const iRank) const
 
void setPiece (case_t const cf, piece_t const piece)
 
void setPiece (case_t const cf, uint8_t const piece)
 
piece_t setGetPiece (column_t const newcol, rank_t const newrank, piece_t const piece)
 
piece_t removePiece (column_t const newcol, rank_t const newrank)
 
void clearPiece (case_t const cf)
 
constexpr bool isFieldEmpty (case_t const cf) const
 
constexpr bool isFieldEmpty (column_t const iColumn, rank_t const iRank) const
 
constexpr case_t getWhiteKingPos () const
 
constexpr case_t getBlackKingPos () const
 
void movePiece (case_t const cf, case_t const ct, piece_t const np)
 
void swapPiece (case_t const cf, piece_t const op, piece_t const np)
 
void clearPiece (case_t const cf, piece_t const op)
 
void restorePiece (case_t const cf, piece_t const op)
 
void moveWhiteKing (case_t const cf, case_t const ct)
 
void moveBlackKing (case_t const cf, case_t const ct)
 
bFen getFEN () const
 
constexpr int8_t pieceCount () const
 
std::string getHashStr () const
 
constexpr hashkey_t getHash () const
 
void setHash (hashkey_t const newHash)
 
boardInfo_t getBoardInfo () const
 
void setBoardInfo (boardInfo_t boardInfo)
 
boardInfo_t applyWhiteMove (bMove const &m)
 
boardInfo_t applyBlackMove (bMove const &m)
 
void unApplyMove (bMove const &m, boardInfo_t const oldBoardInfo)
 exact restoration of basic board using move details
 
boardInfo_t makeBoardMove (column_t const oldcol, rank_t const oldrank, column_t const newcol, rank_t const newrank)
 apply move to check if in check only, board to be discarded as it will be in incomplete state, no hash update no check flag set, etc.
 
void unMakeBoardMove (case_t const &cf, column_t const newcol, rank_t const newrank, boardInfo_t const oldBoardInfo)
 undo makeBoardMove, restoring previous situation
 

Friends

class bPositionEvaluation
 
class PosEvalPositionalBoard
 
class bWhitePiece
 
class bBlackPiece
 
std::ostream & operator<< (std::ostream &os, bBoard const &dt)
 print board
 

Additional Inherited Members

- Protected Member Functions inherited from bBasicBoard
 bBasicBoard ()
 
 bBasicBoard (bBasicBoard &&bb)
 
 bBasicBoard (bFen const &fen)
 
bBasicBoardoperator= (bBasicBoard const &)=delete
 
bBasicBoardoperator= (bBasicBoard &&)=delete
 
void calcHash ()
 Set hash based on board position, also calc pieces Byte 0: bits 4-6 capture count (masked) bit 7 player to move We are using 64 bits for hash.
 
void capturePieceOn (piece_t const capturedPiece, case_t const ct)
 Clear castle flag if rook captured update piece counter, update hash, clear field.
 
void setPieceKU (case_t const cf, piece_t const piece)
 
void setPieceCount (int8_t const n)
 
void incPieceCount ()
 
void decPieceCount ()
 

Detailed Description

board

Definition at line 45 of file board.h.

Constructor & Destructor Documentation

◆ bBoard() [1/3]

bBoard::bBoard ( bBoard const & b)
explicit

Copy board with limited board data, no board history.

Definition at line 20 of file board.cpp.

Referenced by bBlackPiece, bBoard(), bBoard(), operator<<, operator=(), operator=(), and setVariation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bBoard() [2/3]

bBoard::bBoard ( bBoard const & b,
bMove & m )
explicit

Create copy of board with limited board data and history.

Parameters
bexisting board
mmove to be added to history

Definition at line 31 of file board.cpp.

+ Here is the call graph for this function:

◆ bBoard() [3/3]

bBoard::bBoard ( bFen const & fen)
explicit

used by setFENInitialPos

Definition at line 42 of file board.cpp.

+ Here is the call graph for this function:

◆ ~bBoard()

bBoard::~bBoard ( )
inlineoverride

Definition at line 50 of file board.h.

Member Function Documentation

◆ operator=() [1/2]

bBoard & bBoard::operator= ( bBoard const & b)
delete
+ Here is the call graph for this function:

◆ operator=() [2/2]

bBoard & bBoard::operator= ( bBoard && b)
delete
+ Here is the call graph for this function:

◆ invertColours()

void bBoard::invertColours ( )

invert colours update kingpos, update colour to move, castle rights, ...

Todo

castledone, capturedcase, capturedpiece, bmove, eval

epcase

Definition at line 183 of file board.cpp.

Referenced by bel_debug::execute(), and cmd_eval::execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGameStage()

bGameStage bBoard::getGameStage ( ) const
inlineconstexpr

Definition at line 59 of file board.h.

Referenced by PosEvalPositionalBoard::getEvaluation(), PosEvalStaticBoard::getEvaluation(), and getGameStageName().

+ Here is the caller graph for this function:

◆ clearGameStage()

void bBoard::clearGameStage ( )
inline

Definition at line 61 of file board.h.

◆ getGameStageName()

std::string bBoard::getGameStageName ( ) const

Definition at line 167 of file board.cpp.

Referenced by cmd_eval::execute(), and operator std::string().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calcGameStage()

void bBoard::calcGameStage ( )

calculate stage of game to assist in evaluation

Todo
take into account actual moves

Definition at line 139 of file board.cpp.

Referenced by bBoard(), bGame::playGameMove(), and bSearchAlgorithm::SearchBestMove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ needCalcMinorPieces()

bool bBoard::needCalcMinorPieces ( ) const
inlineconstexpr

Definition at line 67 of file board.h.

◆ noNeedCalcMinorPieces()

bool bBoard::noNeedCalcMinorPieces ( ) const
inlineconstexpr

Definition at line 69 of file board.h.

Referenced by calcGameStage(), and calcMinorPieces().

+ Here is the caller graph for this function:

◆ setNeedCalcMinorPieces()

void bBoard::setNeedCalcMinorPieces ( )
inline

Definition at line 71 of file board.h.

Referenced by applyMove().

+ Here is the caller graph for this function:

◆ clearNeedCalcMinorPieces()

void bBoard::clearNeedCalcMinorPieces ( )
inline

Definition at line 73 of file board.h.

Referenced by calcMinorPieces().

+ Here is the caller graph for this function:

◆ calcMinorPieces()

void bBoard::calcMinorPieces ( bool const bForceRecalc = false)

Recalculate minor pieces, used for evaluation and end of game condition in case of less than 5 pieces.

Parameters
bForceRecalcforce to recalculate

Definition at line 68 of file board.cpp.

Referenced by bBoard(), SearchAlphaBeta::CalcBestMove(), SearchAlphaBetaFH::CalcBestMove(), cmd_eval::execute(), invertColours(), SearchAlphaBeta::Quiescence(), and bSearchAlgorithm::SearchBestMove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMove()

bmove_t bBoard::getMove ( ) const
inlineconstexpr

Definition at line 78 of file board.h.

◆ clearMove()

void bBoard::clearMove ( )
inline

Definition at line 80 of file board.h.

Referenced by bGame::revertGameMove().

+ Here is the caller graph for this function:

◆ setMove()

void bBoard::setMove ( bmove_t const bmt)
inline

Definition at line 82 of file board.h.

Referenced by applyMove(), and bGame::playGameMove().

+ Here is the caller graph for this function:

◆ getPreviousMoves()

movesequence_t const & bBoard::getPreviousMoves ( ) const
inline

Definition at line 85 of file board.h.

Referenced by bBoard(), UCIMode::sendInfoSearching(), UCIMode::sendInfoSearching(), XboardMode::sendInfoSearching(), and setVariation().

+ Here is the caller graph for this function:

◆ setPreviousMoves()

void bBoard::setPreviousMoves ( movesequence_t const & v)
inline

Definition at line 87 of file board.h.

Referenced by bSearchAlgorithm::SearchBestMove().

+ Here is the caller graph for this function:

◆ getVariation()

movesequence_t const & bBoard::getVariation ( ) const
inline

Definition at line 89 of file board.h.

Referenced by UCIMode::sendInfoCurrMove(), UCIMode::sendInfoSearching(), UCIMode::sendInfoSearching(), XboardMode::sendInfoSearching(), and setVariation().

+ Here is the caller graph for this function:

◆ clearVariation()

void bBoard::clearVariation ( )
inline

Definition at line 91 of file board.h.

Referenced by bSearchAlgorithm::SearchBestMove().

+ Here is the caller graph for this function:

◆ setVariation()

void bBoard::setVariation ( bBoard const & chldbrd)

Definition at line 227 of file board.cpp.

Referenced by SearchAlphaBeta::CalcBestMove(), and SearchAlphaBetaFH::CalcBestMove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyMove()

boardInfo_t bBoard::applyMove ( bMove const & m)
overridevirtual

modification of board move is kept on previous board newboard does not have move stored and has flag to recalculate minor pieces

Todo
check usage in case of failure, why not return exception?

Reimplemented from bBasicBoard.

Definition at line 217 of file board.cpp.

Referenced by SearchAlphaBeta::CalcBestMove(), SearchAlphaBetaFH::CalcBestMove(), SearchEvalPosOnly::CalcBestMove(), bGame::playGameMove(), and SearchAlphaBeta::Quiescence().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator std::string()

bBoard::operator std::string ( ) const

print board

Todo
add mate condition

Definition at line 240 of file board.cpp.

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ bPositionEvaluation

friend class bPositionEvaluation
friend

Definition at line 100 of file board.h.

Referenced by bPositionEvaluation.

◆ PosEvalPositionalBoard

friend class PosEvalPositionalBoard
friend

Definition at line 101 of file board.h.

Referenced by PosEvalPositionalBoard.

◆ bWhitePiece

friend class bWhitePiece
friend

Definition at line 102 of file board.h.

Referenced by bWhitePiece.

◆ bBlackPiece

friend class bBlackPiece
friend

Definition at line 103 of file board.h.

Referenced by bBlackPiece.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
bBoard const & dt )
friend

print board

Definition at line 274 of file board.cpp.