Belofte version 2.1.8
A promising chess program using the UCI or Winboard interface
|
#include <board.h>
Public Member Functions | |
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 |
virtual void | setInCheck () |
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 |
virtual void | setCapture (piece_t const p, case_t const c) |
Clear castle flag if rook captured update piece counter, update hash, clear field. | |
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 | |
Protected Member Functions | |
bBasicBoard () | |
bBasicBoard (bBasicBoard const &bb) | |
bBasicBoard (bBasicBoard &&bb) | |
bBasicBoard (bFen const &fen) | |
virtual | ~bBasicBoard () |
bBasicBoard & | operator= (bBasicBoard const &)=delete |
bBasicBoard & | operator= (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 | ||
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 | |
|
protected |
|
explicitprotected |
|
explicitprotected |
|
explicitprotected |
Definition at line 35 of file board.cpp.
|
protecteddelete |
|
protecteddelete |
|
inline |
Definition at line 53 of file board.h.
Referenced by bBasicBoard().
|
inline |
Definition at line 54 of file board.h.
Referenced by bBasicBoard(), bBoard::invertColours(), and makeBoardMove().
|
inline |
Definition at line 55 of file board.h.
Referenced by bBoard::invertColours().
|
inline |
Definition at line 58 of file board.h.
Referenced by calcHash(), bWhitePawn::GenerateMoves(), bBlackPawn::GenerateMoves(), getFEN(), bWhitePawn::hasValidMovePreflightCheck(), and bBlackPawn::hasValidMovePreflightCheck().
void bBasicBoard::setEp | ( | case_t const | e | ) |
Definition at line 233 of file board.cpp.
Referenced by bBasicBoard().
|
inline |
Definition at line 60 of file board.h.
Referenced by bBasicBoard().
|
inline |
Definition at line 63 of file board.h.
Referenced by getFEN(), and bPositionEvaluation::isGameEnded().
|
inline |
Definition at line 64 of file board.h.
Referenced by bBasicBoard().
|
inline |
|
inline |
Definition at line 66 of file board.h.
Referenced by setCapture().
bool bBasicBoard::canCastle | ( | ) | const |
Definition at line 243 of file board.cpp.
Referenced by calcHash(), bWhiteKing::GenerateMoves(), bBlackKing::GenerateMoves(), getFEN(), and bBoard::invertColours().
void bBasicBoard::setCastle | ( | uint8_t const | f | ) |
Definition at line 260 of file board.cpp.
Referenced by bBasicBoard(), bBoard::invertColours(), and setCastle().
void bBasicBoard::setCastle | ( | uint8_t const | f, |
bool const | c | ||
) |
void bBasicBoard::clearCastle | ( | uint8_t const | f | ) |
Definition at line 269 of file board.cpp.
Referenced by setCapture(), and setCastle().
bool bBasicBoard::isInCheck | ( | ) | const |
Definition at line 278 of file board.cpp.
Referenced by SearchAlphaBeta::CalcBestMove(), SearchAlphaBetaFH::CalcBestMove(), canCastle(), and SearchAlphaBeta::Quiescence().
|
virtual |
Reimplemented in bBoard.
Definition at line 283 of file board.cpp.
Referenced by bBoard::setInCheck().
|
inline |
Definition at line 80 of file board.h.
Referenced by cmd_usermove::execute(), bBoard::invertColours(), bPositionEvaluation::isGameEnded(), bBoard::minimizing(), bGame::playGameMove(), and bSearchAlgorithm::SearchBestMove().
|
inline |
|
inline |
Definition at line 82 of file board.h.
Referenced by bMoveList::atLeastOneMovePossible(), calcHash(), bMoveList::generateMoves(), getFEN(), makeBoardMove(), and unMakeBoardMove().
1 for white, 2 for black
Definition at line 157 of file board.cpp.
Referenced by bWhitePawn::addCapturePawnMove(), bBlackPawn::addCapturePawnMove(), bWhitePawn::addCapturePromotionMove(), bBlackPawn::addCapturePromotionMove(), bWhitePiece::addMove(), bBlackPiece::addMove(), bWhitePiece::addMoves(), bBlackPiece::addMoves(), bMoveList::atLeastOneMovePossible(), calcHash(), bBoard::calcPieces(), bWhitePiece::canMovePreflightCheck(), bBlackPiece::canMovePreflightCheck(), bWhitePiece::canMovePreflightCheck(), bBlackPiece::canMovePreflightCheck(), bMoveList::generateMoves(), PosEvalStaticBoard::getEndgameEvaluation(), PosEvalPiecesOnly::getEvaluation(), getFEN(), PosEvalStaticBoard::getMatingEvaluation(), PosEvalStaticBoard::getPawnEndingEvaluation(), PosEvalStaticBoard::getRelativeBoardEval(), bBoard::invertColours(), bPieceColour::isAttackedBySlider(), makeBoardMove(), and unMakeBoardMove().
retrieve piece with bounds checking, return field empty in case of out of bounds
Definition at line 171 of file board.cpp.
Referenced by bPieceColour::isAttackedByPiece().
used for promotion move generation
Definition at line 190 of file board.cpp.
Referenced by bMoveList::addBlackPromotionIfValid(), bMoveList::addWhitePromotionIfValid(), makeBoardMove(), and unMakeBoardMove().
void bBasicBoard::setPiece | ( | case_t const | bc, |
uint8_t const | piece | ||
) |
piece_t bBasicBoard::setGetPiece | ( | column_t const | newcol, |
rank_t const | newrank, | ||
piece_t const | piece | ||
) |
used for makeBoardMove
Definition at line 202 of file board.cpp.
Referenced by makeBoardMove().
used for makeBoardMove
Definition at line 212 of file board.cpp.
Referenced by makeBoardMove().
void bBasicBoard::clearPiece | ( | case_t const | bc | ) |
Definition at line 228 of file board.cpp.
Referenced by makeBoardMove(), and unMakeBoardMove().
bool bBasicBoard::isFieldEmpty | ( | case_t const | bc | ) | const |
Definition at line 178 of file board.cpp.
Referenced by bWhitePiece::addMove(), bBlackPiece::addMove(), bWhitePiece::addMoves(), bBlackPiece::addMoves(), bWhitePawn::addNonCaptureDoublePawnMove(), bBlackPawn::addNonCaptureDoublePawnMove(), bWhitePawn::addNonCapturePawnMove(), bBlackPawn::addNonCapturePawnMove(), bWhitePawn::addNonCapturePromotionMove(), bBlackPawn::addNonCapturePromotionMove(), bWhitePawn::GenerateMoves(), bBlackPawn::GenerateMoves(), bWhiteKing::GenerateMoves(), and bBlackKing::GenerateMoves().
Clear castle flag if rook captured update piece counter, update hash, clear field.
Reimplemented in bBoard.
Definition at line 297 of file board.cpp.
Referenced by bBoard::setCapture().
|
inline |
Definition at line 102 of file board.h.
Referenced by bMoveList::addBlackMoveIfValid(), bMoveList::addBlackPromotionIfValid(), bMoveList::addWhiteMoveIfValid(), bMoveList::addWhitePromotionIfValid(), bWhitePiece::canMovePreflightCheck(), bWhitePiece::canMovePreflightCheck(), bBlackPiece::isAttacked(), and bPositionEvaluation::isGameEnded().
|
inline |
Definition at line 103 of file board.h.
Referenced by bMoveList::addBlackMoveIfValid(), bMoveList::addBlackPromotionIfValid(), bMoveList::addWhiteMoveIfValid(), bMoveList::addWhitePromotionIfValid(), bBlackPiece::canMovePreflightCheck(), bBlackPiece::canMovePreflightCheck(), bWhitePiece::isAttacked(), and bPositionEvaluation::isGameEnded().
bFen bBasicBoard::getFEN | ( | ) | const |
Definition at line 114 of file board.cpp.
Referenced by bel_debug::execute().
u_positionFlags_t bBasicBoard::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.
oldcol | column from |
oldrank | rank from |
newcol | column to |
newrank | rank to |
promotion | piece |
Definition at line 400 of file board.cpp.
Referenced by bWhitePiece::canMovePreflightCheck(), bBlackPiece::canMovePreflightCheck(), bWhitePiece::canMovePreflightCheck(), and bBlackPiece::canMovePreflightCheck().
void bBasicBoard::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
cf | case from |
newcol | column to |
newrank | rank to |
oldFlags | the positionFlags of the old position |
promotion | move signals return to pawn |
Definition at line 481 of file board.cpp.
Referenced by bWhitePiece::canMovePreflightCheck(), bBlackPiece::canMovePreflightCheck(), bWhitePiece::canMovePreflightCheck(), and bBlackPiece::canMovePreflightCheck().
|
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.
Definition at line 355 of file board.cpp.
Referenced by bBasicBoard(), and bBoard::invertColours().
calculate and set hash
used for setboard only
Definition at line 221 of file board.cpp.
Referenced by bBasicBoard(), and bBoard::invertColours().
uint64_t bBasicBoard::u_positionFlags = 0ULL |
Definition at line 122 of file board.h.
Referenced by bBasicBoard(), makeBoardMove(), and unMakeBoardMove().
case_t bBasicBoard::m_whiteKing |
Definition at line 124 of file board.h.
Referenced by getWhiteKingPos(), makeBoardMove(), moveWhiteKing(), setPieceKU(), and unMakeBoardMove().
case_t bBasicBoard::m_blackKing |
Definition at line 125 of file board.h.
Referenced by getBlackKingPos(), makeBoardMove(), moveBlackKing(), setPieceKU(), and unMakeBoardMove().
plynum_t bBasicBoard::m_ply |
Definition at line 126 of file board.h.
Referenced by decPly(), getColourToMove(), getMoveNumber(), getPly(), incPly(), setPly(), and whiteToMove().
case_t bBasicBoard::m_ep |
movenum50_t bBasicBoard::m_ply50moves |
Definition at line 128 of file board.h.
Referenced by clearPly50Moves(), getPly50Moves(), incPly50Moves(), and setPly50Moves().
uint8_t bBasicBoard::m_castling |
Definition at line 129 of file board.h.
Referenced by canCastle(), canCastle(), clearCastle(), clearInCheck(), isInCheck(), setCastle(), and setInCheck().
piece_t bBasicBoard::m_capturedpiece |
4 castling bits as uints as copy ctor stumbles on bool array
Definition at line 130 of file board.h.
Referenced by bBoard::isCapture(), and bBoard::setCapture().
union { ... } bBasicBoard |
|
protected |
Definition at line 133 of file board.h.
Referenced by calcHash(), clearCastle(), getHash(), getHashStr(), moveBlackKing(), movePiece(), moveWhiteKing(), setCapture(), setCastle(), setEp(), setHash(), and swapPiece().