Belofte  version 2.1.5
A promising chess program using the UCI or Winboard interface
bBasicBoard Class Reference

Public Member Functions

int16_t getPly () const
 
void setPly (int16_t const p)
 
case_t getEp () const
 
void setEp (case_t const e)
 
int16_t getPly50Moves () const
 
void setPly50Moves (int16_t const p)
 
bool canCastle (uint8_t const f) const
 
void setCastle (uint8_t const f, bool const c)
 
void clearCastle (uint8_t const f)
 
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 More...
 
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 More...
 
void setPiece (case_t const bc, piece_t const piece)
 used for promotion move generation only More...
 
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 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
 
virtual void setCapture (piece_t const p, case_t const c)
 Clear castle flag if rook captured update piece counter, update hash, clear field. More...
 
bFen getFEN () const
 
std::string getHashStr () const
 

Protected Member Functions

 bBasicBoard ()
 
 bBasicBoard (bFen const &fen)
 
virtual ~bBasicBoard ()
 
 bBasicBoard (bBasicBoard const &)=default
 
 bBasicBoard (bBasicBoard &&)=default
 
bBasicBoardoperator= (bBasicBoard const &)=delete
 
bBasicBoardoperator= (bBasicBoard &&)=delete
 
void setPieceKU (case_t const bc, piece_t const piece)
 used for setboard only More...
 
case_t getWhiteKingPos () const
 
case_t getBlackKingPos () const
 
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. More...
 
hashkey_t getHash () const
 calculate and set hash More...
 

Protected Attributes

hashkey_t m_hash
 
piece_t m_capturedpiece = tPiece::P_EMPTY
 

Detailed Description

Definition at line 39 of file board.h.

Constructor & Destructor Documentation

◆ bBasicBoard() [1/4]

bBasicBoard::bBasicBoard ( )
protected

◆ bBasicBoard() [2/4]

bBasicBoard::bBasicBoard ( bFen const &  fen)
explicitprotected
Todo:
check legality of position: Max number of pieces of each type e.g. K=1, Q=9 -#pawns, N=10 -#pawns colour of bishops, double in-check, in case of ep, adjacent pawn movenumber if not initial position, location of pawns, position of king and rooks in case of castle allowed (att. 960) for each promoted piece, an opponent piece must have been taken

Definition at line 21 of file board.cpp.

+ Here is the call graph for this function:

◆ ~bBasicBoard()

bBasicBoard::~bBasicBoard ( )
protectedvirtual

Definition at line 12 of file board.cpp.

◆ bBasicBoard() [3/4]

bBasicBoard::bBasicBoard ( bBasicBoard const &  )
protecteddefault

◆ bBasicBoard() [4/4]

bBasicBoard::bBasicBoard ( bBasicBoard &&  )
protecteddefault

Member Function Documentation

◆ operator=() [1/2]

bBasicBoard& bBasicBoard::operator= ( bBasicBoard const &  )
protecteddelete

◆ operator=() [2/2]

bBasicBoard& bBasicBoard::operator= ( bBasicBoard &&  )
protecteddelete

◆ getPly()

int16_t bBasicBoard::getPly ( ) const
inline

Definition at line 54 of file board.h.

Referenced by bBasicBoard(), and bBoard::invert().

+ Here is the caller graph for this function:

◆ setPly()

void bBasicBoard::setPly ( int16_t const  p)
inline

Definition at line 55 of file board.h.

Referenced by bBasicBoard(), and bBoard::invert().

+ Here is the caller graph for this function:

◆ getEp()

case_t bBasicBoard::getEp ( ) const
inline

Definition at line 57 of file board.h.

Referenced by calcHash(), bWhitePawn::GenerateMoves(), bBlackPawn::GenerateMoves(), and getFEN().

+ Here is the caller graph for this function:

◆ setEp()

void bBasicBoard::setEp ( case_t const  e)

Definition at line 184 of file board.cpp.

Referenced by bBasicBoard().

+ Here is the caller graph for this function:

◆ getPly50Moves()

int16_t bBasicBoard::getPly50Moves ( ) const
inline

Definition at line 59 of file board.h.

Referenced by getFEN(), and bPositionEvaluation::isGameEnded().

+ Here is the caller graph for this function:

◆ setPly50Moves()

void bBasicBoard::setPly50Moves ( int16_t const  p)
inline

Definition at line 60 of file board.h.

Referenced by bBasicBoard(), and setCapture().

+ Here is the caller graph for this function:

◆ canCastle()

bool bBasicBoard::canCastle ( uint8_t const  f) const

Definition at line 194 of file board.cpp.

Referenced by calcHash(), clearCastle(), bWhiteKing::GenerateMoves(), bBlackKing::GenerateMoves(), getFEN(), and bBoard::invert().

+ Here is the caller graph for this function:

◆ setCastle()

void bBasicBoard::setCastle ( uint8_t const  f,
bool const  c 
)

Definition at line 199 of file board.cpp.

Referenced by bBasicBoard(), clearCastle(), and bBoard::invert().

+ Here is the caller graph for this function:

◆ clearCastle()

void bBasicBoard::clearCastle ( uint8_t const  f)

Definition at line 208 of file board.cpp.

Referenced by setCapture().

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

◆ whiteToMove()

bool bBasicBoard::whiteToMove ( ) const
inline

◆ getMoveNumber()

int16_t bBasicBoard::getMoveNumber ( ) const
inline

Definition at line 68 of file board.h.

Referenced by getFEN().

+ Here is the caller graph for this function:

◆ getColourToMove()

side_t bBasicBoard::getColourToMove ( ) const
inline

◆ getPiece() [1/2]

◆ getPiece() [2/2]

piece_t bBasicBoard::getPiece ( column_t const  iColumn,
rank_t const  iRank 
) const

Definition at line 143 of file board.cpp.

+ Here is the call graph for this function:

◆ getPieceCtl()

piece_t bBasicBoard::getPieceCtl ( column_t const  iColumn,
rank_t const  iRank 
) const

retrieve piece with bounds checking, return field empty in case of out of bounds

Definition at line 152 of file board.cpp.

Referenced by bPieceColour::isAttackedByPiece().

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

◆ setPiece()

void bBasicBoard::setPiece ( case_t const  bc,
piece_t const  piece 
)

used for promotion move generation only

Definition at line 171 of file board.cpp.

◆ movePiece()

void bBasicBoard::movePiece ( case_t const  f,
case_t const  t,
piece_t const  p 
)

Definition at line 241 of file board.cpp.

◆ swapPiece()

void bBasicBoard::swapPiece ( case_t const  t,
piece_t const  op,
piece_t const  np 
)

Definition at line 248 of file board.cpp.

◆ moveWhiteKing()

void bBasicBoard::moveWhiteKing ( case_t const  f,
case_t const  t 
)

Definition at line 254 of file board.cpp.

◆ moveBlackKing()

void bBasicBoard::moveBlackKing ( case_t const  f,
case_t const  t 
)

Definition at line 262 of file board.cpp.

◆ isFieldEmpty() [1/2]

bool bBasicBoard::isFieldEmpty ( case_t const  bc) const

◆ isFieldEmpty() [2/2]

bool bBasicBoard::isFieldEmpty ( column_t const  iColumn,
rank_t const  iRank 
) const

Definition at line 164 of file board.cpp.

+ Here is the call graph for this function:

◆ setCapture()

void bBasicBoard::setCapture ( piece_t const  p,
case_t const  c 
)
virtual

Clear castle flag if rook captured update piece counter, update hash, clear field.

Reimplemented in bBoard.

Definition at line 221 of file board.cpp.

Referenced by bBoard::setCapture().

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

◆ getFEN()

bFen bBasicBoard::getFEN ( ) const

Definition at line 92 of file board.cpp.

Referenced by bel_debug::execute().

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

◆ getHashStr()

std::string bBasicBoard::getHashStr ( ) const

Definition at line 315 of file board.cpp.

◆ setPieceKU()

void bBasicBoard::setPieceKU ( case_t const  bc,
piece_t const  piece 
)
protected

used for setboard only

Definition at line 177 of file board.cpp.

Referenced by bBasicBoard(), and bBoard::invert().

+ Here is the caller graph for this function:

◆ getWhiteKingPos()

case_t bBasicBoard::getWhiteKingPos ( ) const
inlineprotected

Definition at line 90 of file board.h.

Referenced by bMoveList::generateEscapeKingMove(), and bPositionEvaluation::isGameEnded().

+ Here is the caller graph for this function:

◆ getBlackKingPos()

case_t bBasicBoard::getBlackKingPos ( ) const
inlineprotected

Definition at line 91 of file board.h.

Referenced by bMoveList::generateEscapeKingMove(), and bPositionEvaluation::isGameEnded().

+ Here is the caller graph for this function:

◆ calcHash()

void bBasicBoard::calcHash ( )
protected

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.

Todo:
TOCHECK: increase to 64 bits, is there added value

Definition at line 279 of file board.cpp.

Referenced by bBasicBoard(), and bBoard::invert().

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

◆ getHash()

hashkey_t bBasicBoard::getHash ( ) const
inlineprotected

calculate and set hash

Definition at line 93 of file board.h.

Member Data Documentation

◆ m_hash

hashkey_t bBasicBoard::m_hash
protected

◆ m_capturedpiece

piece_t bBasicBoard::m_capturedpiece = tPiece::P_EMPTY
protected

Definition at line 96 of file board.h.

Referenced by bBoard::isCapture(), and bBoard::setCapture().