Belofte version 2.1.8
A promising chess program using the UCI or Winboard interface
bBoard Class Referencefinal

board More...

#include <board.h>

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

Public Member Functions

 bBoard (bBoard &&b) noexcept
 Used when Push board on gamestack (playGameMove)
 
 bBoard (bBoard const &b)
 Used by bPgnMove ctor, popuplateMoveList, atLeastOneMovePossible movesinpgnformat.
 
 bBoard (bBoard const &b, movenum_t const moveid)
 Create copy of board with move applied on it, clear fields that reflect state before move is played used by CalcBestMove.
 
 bBoard (bBoard const &b, bMove const &m)
 Create copy of board with move applied on it, clear fields that reflect state before move is played, used for SearchPerft::CalcBestMove, add..MoveIfValid.
 
 bBoard (bBoard const &b, bMove &m)
 Create copy of board with move applied on it, clear fields that reflect state before move is played, used for playGameMove and applyMove Signature difference in const only!!
 
 bBoard (bFen const &fen)
 used by setFENInitialPos
 
 ~bBoard () override
 
bBoardoperator= (bBoard const &)=delete
 
bBoardoperator= (bBoard &&)=delete
 
 operator std::string () const
 
bool atLeastOneMovePossible () const
 see if at least one move can be played e.g.
 
bMoveListgetMoveListRef ()
 return reference to movelist
 
bMove const & getMove (movenum_t const moveid) const
 
void calcPieces ()
 
void calcGameStage ()
 calculate pieces
 
bool isNonSilent () const
 calculate gamestage
 
void setNonSilent ()
 
bool isCapture () const
 
void setCapture (piece_t const p, case_t const c) override
 set non-silent flag, store captured piece and case (for undo)
 
void setInCheck () final
 
void invertColours ()
 invert colours update kingpos, update colour to move, castle rights, ...
 
bGameStage getStage () const
 
bScore getBoardEvaluation () const
 
void setBoardEvaluation (bScore const s)
 
bScore minimizing () const
 
bool castleDoneWhite () const
 -1 black to move, 1 white to move
 
bool castleDoneBlack () const
 
void setCastleDoneWhite (bool const c)
 
void setCastleDoneBlack (bool const c)
 
movesequence_t const & getPreviousMoves () const
 
void setPreviousMoves (movesequence_t const &v)
 
basicmove_t const & getMovePlayed () const
 
movesequence_t const & getVariation () const
 
void clearVariation ()
 
void setVariation (bBoard const &chldbrd)
 
- Public Member Functions inherited from bBasicBoard
plynum_t getPly () const
 
void setPly (plynum_t const p)
 
void incPly ()
 
void decPly ()
 
case_t getEp () const
 
void setEp (case_t const e)
 
void clearEp ()
 
movenum50_t getPly50Moves () const
 
void setPly50Moves (movenum50_t const p)
 
movenum50_t incPly50Moves ()
 
void clearPly50Moves ()
 
bool canCastle () const
 
bool canCastle (uint8_t const f) const
 
void setCastle (uint8_t const f)
 
void setCastle (uint8_t const f, bool const c)
 
void clearCastle (uint8_t const f)
 
bool isInCheck () const
 
void clearInCheck ()
 
bool whiteToMove () const
 
int16_t getMoveNumber () const
 
side_t getColourToMove () const
 
piece_t getPiece (case_t const bc) const
 1 for white, 2 for black
 
piece_t getPiece (column_t const iColumn, rank_t const iRank) const
 
piece_t getPieceCtl (column_t const iColumn, rank_t const iRank) const
 retrieve piece with bounds checking, return field empty in case of out of bounds
 
void setPiece (case_t const bc, piece_t const piece)
 used for promotion move generation
 
void setPiece (case_t const bc, uint8_t const piece)
 used for unMakeBoardMove
 
piece_t setGetPiece (column_t const newcol, rank_t const newrank, piece_t const piece)
 used for makeBoardMove
 
piece_t removePiece (column_t const newcol, rank_t const newrank)
 used for makeBoardMove
 
void movePiece (case_t const f, case_t const t, piece_t const p)
 
void swapPiece (case_t const t, piece_t const op, piece_t const np)
 
void clearPiece (case_t const bc)
 
void moveWhiteKing (case_t const f, case_t const t)
 
void moveBlackKing (case_t const f, case_t const t)
 
bool isFieldEmpty (case_t const bc) const
 
bool isFieldEmpty (column_t const iColumn, rank_t const iRank) const
 
case_t getWhiteKingPos () const
 
case_t getBlackKingPos () const
 
bFen getFEN () const
 
std::string getHashStr () const
 
hashkey_t getHash () const
 
void setHash (hashkey_t const newHash)
 
u_positionFlags_t makeBoardMove (column_t const oldcol, rank_t const oldrank, column_t const newcol, rank_t const newrank, piece_t const promotion)
 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, u_positionFlags_t const oldFlags, piece_t const promotion)
 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 const &bb)
 
 bBasicBoard (bBasicBoard &&bb)
 
 bBasicBoard (bFen const &fen)
 
virtual ~bBasicBoard ()
 
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 setPieceKU (case_t const bc, piece_t const piece)
 calculate and set hash
 
- Protected Attributes inherited from bBasicBoard
union { 
 
   uint64_t   u_positionFlags = 0ULL 
 
   struct { 
 
      case_t   m_whiteKing 
 
      case_t   m_blackKing 
 
      plynum_t   m_ply 
 
      case_t   m_ep 
 
      movenum50_t   m_ply50moves 
 
      uint8_t   m_castling 
 
      piece_t   m_capturedpiece 
 4 castling bits as uints as copy ctor stumbles on bool array More...
 
   }  
 
};  
 
hashkey_t m_hash
 

Detailed Description

board

Definition at line 147 of file board.h.

Constructor & Destructor Documentation

◆ bBoard() [1/6]

bBoard::bBoard ( bBoard &&  b)
explicitnoexcept

Used when Push board on gamestack (playGameMove)

Definition at line 571 of file board.cpp.

◆ bBoard() [2/6]

bBoard::bBoard ( bBoard const &  b)
explicit

Used by bPgnMove ctor, popuplateMoveList, atLeastOneMovePossible movesinpgnformat.

Todo:
make function obsolete to avoid confusion

Definition at line 562 of file board.cpp.

◆ bBoard() [3/6]

bBoard::bBoard ( bBoard const &  b,
movenum_t const  moveid 
)
explicit

Create copy of board with move applied on it, clear fields that reflect state before move is played used by CalcBestMove.

Parameters
bexisting board, moves may not have been generated yet
moveidto be applied

Definition at line 599 of file board.cpp.

+ Here is the call graph for this function:

◆ bBoard() [4/6]

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

Create copy of board with move applied on it, clear fields that reflect state before move is played, used for SearchPerft::CalcBestMove, add..MoveIfValid.

Parameters
bexisting board
mmove to be applied

Definition at line 637 of file board.cpp.

◆ bBoard() [5/6]

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

Create copy of board with move applied on it, clear fields that reflect state before move is played, used for playGameMove and applyMove Signature difference in const only!!

Parameters
bexisting board
mmove to be applied

Definition at line 621 of file board.cpp.

+ Here is the call graph for this function:

◆ bBoard() [6/6]

bBoard::bBoard ( bFen const &  fen)
explicit

used by setFENInitialPos

Definition at line 645 of file board.cpp.

+ Here is the call graph for this function:

◆ ~bBoard()

bBoard::~bBoard ( )
override

Definition at line 662 of file board.cpp.

Member Function Documentation

◆ operator=() [1/2]

bBoard & bBoard::operator= ( bBoard const &  )
delete

◆ operator=() [2/2]

bBoard & bBoard::operator= ( bBoard &&  )
delete

◆ operator std::string()

bBoard::operator std::string ( ) const

Definition at line 988 of file board.cpp.

+ Here is the call graph for this function:

◆ atLeastOneMovePossible()

bool bBoard::atLeastOneMovePossible ( ) const

see if at least one move can be played e.g.

(stale-)mate eval

Definition at line 962 of file board.cpp.

Referenced by bPositionEvaluation::isGameEnded().

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

◆ getMoveListRef()

◆ getMove()

bMove const & bBoard::getMove ( movenum_t const  moveid) const

Definition at line 967 of file board.cpp.

Referenced by bBoard(), bGame::evalEpdPosition(), bSearchAlgorithm::sendInfoCurrMove(), and bGame::WaitForSearchEnd().

+ Here is the caller graph for this function:

◆ calcPieces()

void bBoard::calcPieces ( )

Definition at line 672 of file board.cpp.

Referenced by bBoard(), bBoard(), bBoard(), and invertColours().

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

◆ calcGameStage()

void bBoard::calcGameStage ( )

calculate pieces

Todo:
take into account actual moves

Definition at line 737 of file board.cpp.

Referenced by bBoard(), bBoard(), and bBoard().

+ Here is the caller graph for this function:

◆ isNonSilent()

bool bBoard::isNonSilent ( ) const
inline

calculate gamestage

Definition at line 170 of file board.h.

◆ setNonSilent()

void bBoard::setNonSilent ( )
inline

Definition at line 171 of file board.h.

◆ isCapture()

bool bBoard::isCapture ( ) const
inline

Definition at line 172 of file board.h.

◆ setCapture()

void bBoard::setCapture ( piece_t const  p,
case_t const  c 
)
overridevirtual

set non-silent flag, store captured piece and case (for undo)

Reimplemented from bBasicBoard.

Definition at line 795 of file board.cpp.

+ Here is the call graph for this function:

◆ setInCheck()

void bBoard::setInCheck ( )
finalvirtual

Reimplemented from bBasicBoard.

Definition at line 803 of file board.cpp.

+ 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, moveplayed, eval

epcase

force recalculation of pieces

Definition at line 764 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:

◆ getStage()

bGameStage bBoard::getStage ( ) const
inline

Definition at line 177 of file board.h.

Referenced by cmd_eval::execute(), PosEvalStaticBoard::getEvaluation(), and PosEvalPositionalBoard::getEvaluation().

+ Here is the caller graph for this function:

◆ getBoardEvaluation()

bScore bBoard::getBoardEvaluation ( ) const
inline

Definition at line 178 of file board.h.

Referenced by bSearchAlgorithm::RetrieveBoardEvaluation().

+ Here is the caller graph for this function:

◆ setBoardEvaluation()

void bBoard::setBoardEvaluation ( bScore const  s)
inline

Definition at line 179 of file board.h.

Referenced by bSearchAlgorithm::RetrieveBoardEvaluation().

+ Here is the caller graph for this function:

◆ minimizing()

bScore bBoard::minimizing ( ) const
inline

Definition at line 180 of file board.h.

Referenced by bGame::EvalForPlayer(), cmd_eval::execute(), bSearchAlgorithm::SearchBestMove(), bSearchAlgorithm::sendInfoScore(), and bSearchAlgorithm::sendInfoSearching().

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

◆ castleDoneWhite()

bool bBoard::castleDoneWhite ( ) const
inline

-1 black to move, 1 white to move

Definition at line 181 of file board.h.

◆ castleDoneBlack()

bool bBoard::castleDoneBlack ( ) const
inline

Definition at line 182 of file board.h.

◆ setCastleDoneWhite()

void bBoard::setCastleDoneWhite ( bool const  c)
inline

Definition at line 183 of file board.h.

◆ setCastleDoneBlack()

void bBoard::setCastleDoneBlack ( bool const  c)
inline

Definition at line 184 of file board.h.

◆ getPreviousMoves()

movesequence_t const & bBoard::getPreviousMoves ( ) const
inline

Definition at line 186 of file board.h.

Referenced by bBoard(), UCIMode::sendInfoCurrMove(), UCIMode::sendInfoScore(), 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 187 of file board.h.

Referenced by bSearchAlgorithm::SearchBestMove().

+ Here is the caller graph for this function:

◆ getMovePlayed()

basicmove_t const & bBoard::getMovePlayed ( ) const
inline

Definition at line 188 of file board.h.

◆ getVariation()

movesequence_t const & bBoard::getVariation ( ) const
inline

Definition at line 189 of file board.h.

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

+ Here is the caller graph for this function:

◆ clearVariation()

void bBoard::clearVariation ( )

Definition at line 974 of file board.cpp.

Referenced by bSearchAlgorithm::SearchBestMove().

+ Here is the caller graph for this function:

◆ setVariation()

void bBoard::setVariation ( bBoard const &  chldbrd)

Definition at line 979 of file board.cpp.

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

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

Friends And Related Symbol Documentation

◆ bPositionEvaluation

friend class bPositionEvaluation
friend

Definition at line 194 of file board.h.

◆ PosEvalPositionalBoard

friend class PosEvalPositionalBoard
friend

Definition at line 195 of file board.h.

◆ bWhitePiece

friend class bWhitePiece
friend

Definition at line 196 of file board.h.

◆ bBlackPiece

friend class bBlackPiece
friend

Definition at line 197 of file board.h.

◆ operator<<

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

print board

Definition at line 1022 of file board.cpp.

Member Data Documentation

◆ u_boardFlags1

uint64_t bBoard::u_boardFlags1 = 0ULL

Definition at line 208 of file board.h.

◆ m_moveplayed

basicmove_t bBoard::m_moveplayed

Definition at line 210 of file board.h.

Referenced by getMovePlayed().

◆ m_bNonSilent

uint8_t bBoard::m_bNonSilent

Definition at line 211 of file board.h.

Referenced by isNonSilent(), setCapture(), setInCheck(), and setNonSilent().

◆ m_piecesonboard

uint8_t bBoard::m_piecesonboard

Definition at line 212 of file board.h.

Referenced by calcGameStage(), calcPieces(), and invertColours().

◆ m_whiteminor

uint8_t bBoard::m_whiteminor

Definition at line 213 of file board.h.

Referenced by calcGameStage(), and calcPieces().

◆ m_blackminor

uint8_t bBoard::m_blackminor

Definition at line 214 of file board.h.

Referenced by calcGameStage(), and calcPieces().

◆ m_gamestage

bGameStage bBoard::m_gamestage

Definition at line 215 of file board.h.

Referenced by calcGameStage(), and getStage().

◆ m_capturedcase

case_t bBoard::m_capturedcase

Definition at line 216 of file board.h.

Referenced by setCapture().

◆ u_boardFlags2

uint32_t bBoard::u_boardFlags2

Definition at line 221 of file board.h.

◆ m_castledoneWhite

uint8_t bBoard::m_castledoneWhite

Definition at line 223 of file board.h.

Referenced by castleDoneWhite(), and setCastleDoneWhite().

◆ m_castledoneBlack

uint8_t bBoard::m_castledoneBlack

Definition at line 224 of file board.h.

Referenced by castleDoneBlack(), and setCastleDoneBlack().

◆ m_boardeval

bScore bBoard::m_boardeval = SCORE_UNDEFINED

Definition at line 225 of file board.h.

Referenced by bBoard(), getBoardEvaluation(), and setBoardEvaluation().