|
HooverChessUtils_PgnReader 0.9.0
|
The chessboard. More...
#include <chessboard.h>

Public Member Functions | |
| ChessBoard () noexcept | |
| Constructor (default) | |
| ChessBoard (const ChessBoard &) noexcept=default | |
| Constructor (copy) | |
| ChessBoard (ChessBoard &&) noexcept=default | |
| Constructor (move) | |
| ChessBoard & | operator= (const ChessBoard &) noexcept=default |
| Assignment. | |
| ChessBoard & | operator= (ChessBoard &&) noexcept=default |
| Move assignment. | |
| ~ChessBoard () noexcept=default | |
| Destructor. | |
| void | setBoard (const ArrayBoard &board, Square whiteLongCastleRook, Square whiteShortCastleRook, Square blackLongCastleRook, Square blackShortCastleRook, Square epSquare, std::uint_fast8_t halfMoveClock, std::uint_fast32_t plyNum) |
| Sets the board from an array board (aka Mailbox) | |
| void | getArrayBoard (ArrayBoard &out_board) const noexcept |
Extracts the current position as an ArrayBoard. | |
| void | setBoard (const BitBoard &board, Square whiteLongCastleRook, Square whiteShortCastleRook, Square blackLongCastleRook, Square blackShortCastleRook, Square epSquare, std::uint_fast8_t halfMoveClock, std::uint_fast32_t plyNum) |
Sets the board from SquareSets (bit board) | |
| void | loadFEN (std::string_view fen) |
| Sets the board from FEN. | |
| PositionStatus | determineStatus () const noexcept |
| Determines the status of the position. | |
| void | loadStartPos () noexcept |
| Loads the starting position. | |
| void | printBoard () const |
| Prints the current board to stdout. This is intended only for debugging purposes. | |
| Piece | getSquarePieceNoColor (Square sq) const noexcept |
| Returns the piece on a specified square. | |
| PieceAndColor | getSquarePiece (Square sq) const noexcept |
| Returns the piece and color on a specified square. | |
| SquareSet | getOccupancyMask () const noexcept |
| Returns squares that are occupied by pieces (including pawns). | |
| SquareSet | getWhitePieces () const noexcept |
| Returns squares occupied by white pieces (including pawns). | |
| SquareSet | getBlackPieces () const noexcept |
| Returns squares occupied by white pieces (including pawns). | |
| SquareSet | getPiecesInTurn () const noexcept |
| Returns squares that are occupied by pieces (including pawns) that belong to the side to move. | |
| SquareSet | getPawns () const noexcept |
| Returns squares occupied by pawns. | |
| SquareSet | getKnights () const noexcept |
| Returns squares occupied by knights. | |
| SquareSet | getBishops () const noexcept |
| Returns squares occupied by bishops. | |
| SquareSet | getRooks () const noexcept |
| Returns squares occupied by rooks. | |
| SquareSet | getQueens () const noexcept |
| Returns squares occupied by queens. | |
| SquareSet | getBishopsAndQueens () const noexcept |
| Returns squares occupied by bishops and queens (diagonal sliders) | |
| SquareSet | getRooksAndQueens () const noexcept |
| Returns squares occupied by rooks and queens (horizontal/vertical sliders) | |
| SquareSet | getKings () const noexcept |
| Returns squares occupied by kings. | |
| Square | getKingInTurn () const noexcept |
| Returns the square of the king in turn. | |
| Square | getKingNotInTurn () const noexcept |
| Returns the square of the king not in turn. | |
| bool | isInCheck () const noexcept |
| Returns whether the king is in check. | |
| SquareSet | getCheckers () const noexcept |
| Returns squares occupied by checkers. | |
| SquareSet | getPinnedPieces () const noexcept |
| Returns squares occupied by absolutely pinned pieces. | |
| Square | getWhiteLongCastleRook () const noexcept |
Shorthand for . | |
| Square | getWhiteShortCastleRook () const noexcept |
Shorthand for . | |
| Square | getBlackLongCastleRook () const noexcept |
Shorthand for . | |
| Square | getBlackShortCastleRook () const noexcept |
Shorthand for . | |
| Square | getCastlingRook (Color c, bool shortCastling) const noexcept |
Returns castling rook square if castling rights apply or Square::NONE if no castling rights. | |
| Square | getEpSquare () const noexcept |
Returns the en-passant square or Square::NONE if en-passant capture is not possible. | |
| std::uint_fast8_t | getHalfMoveClock () const noexcept |
| Current half-move clock. | |
| std::uint_fast32_t | getCurrentPlyNum () const noexcept |
| Full move counter in plies. | |
| Color | getTurn () const noexcept |
| Returns side to move. | |
| Move | generateSingleMoveForPawnAndDestNoCapture (SquareSet srcSqMask, Square dst) const noexcept |
| Generates a legal non-promoting, non-capturing pawn move with a known destination square. | |
| Move | generateSingleMoveForPawnAndDestCapture (SquareSet srcSqMask, Square dst) const noexcept |
| Generates a legal non-promoting, capturing pawn move with a known destination square. | |
| Move | generateSingleMoveForPawnAndDestPromoNoCapture (SquareSet srcSqMask, Square dst, Piece promo) const noexcept |
| Generates a legal promoting, non-capturing pawn move with a known destination square. | |
| Move | generateSingleMoveForPawnAndDestPromoCapture (SquareSet srcSqMask, Square dst, Piece promo) const noexcept |
| Generates a legal promoting, capturing pawn move with a known destination square. | |
| Move | generateSingleMoveForKnightAndDest (SquareSet srcSqMask, Square dst) const noexcept |
| Generates a legal knight move with a known destination square. May be capturing. | |
| Move | generateSingleMoveForBishopAndDest (SquareSet srcSqMask, Square dst) const noexcept |
| Generates a legal bishop move with a known destination square. May be capturing. | |
| Move | generateSingleMoveForRookAndDest (SquareSet srcSqMask, Square dst) const noexcept |
| Generates a legal rook move with a known destination square. May be capturing. | |
| Move | generateSingleMoveForQueenAndDest (SquareSet srcSqMask, Square dst) const noexcept |
| Generates a legal queen move with a known destination square. May be capturing. | |
| Move | generateSingleMoveForKingAndDest (SquareSet srcSqMask, Square dst) const noexcept |
| Generates a legal king move with a known destination square. May be capturing. | |
| Move | generateSingleMoveForShortCastling () const noexcept |
| Generates a legal short castling move. | |
| Move | generateSingleMoveForLongCastling () const noexcept |
| Generates a legal long castling move. | |
| std::size_t | generateMovesForPawnAndDestNoCapture (ShortMoveList &moves, SquareSet srcSqMask, Square dst) const noexcept |
| Generates a list of legal non-promoting, non-capturing pawn moves with a known destination square. | |
| std::size_t | generateMovesForPawnAndDestCapture (ShortMoveList &moves, SquareSet srcSqMask, Square dst) const noexcept |
| Generates a list of legal non-promoting, capturing pawn moves with a known destination square. | |
| std::size_t | generateMovesForPawnAndDestPromoNoCapture (ShortMoveList &moves, SquareSet srcSqMask, Square dst, Piece promo) const noexcept |
| Generates a list of legal promoting, non-capturing pawn moves with a known destination square. | |
| std::size_t | generateMovesForPawnAndDestPromoCapture (ShortMoveList &moves, SquareSet srcSqMask, Square dst, Piece promo) const noexcept |
| Generates a list of legal promoting, capturing pawn moves with a known destination square. | |
| std::size_t | generateMovesForKnightAndDest (ShortMoveList &moves, SquareSet srcSqMask, Square dst) const noexcept |
| Generates a list of legal knight moves with a known destination square. May be capturing. | |
| std::size_t | generateMovesForBishopAndDest (ShortMoveList &moves, SquareSet srcSqMask, Square dst) const noexcept |
| Generates a list of legal bishop moves with a known destination square. May be capturing. | |
| std::size_t | generateMovesForRookAndDest (ShortMoveList &moves, SquareSet srcSqMask, Square dst) const noexcept |
| Generates a list of legal rook moves with a known destination square. May be capturing. | |
| std::size_t | generateMovesForQueenAndDest (ShortMoveList &moves, SquareSet srcSqMask, Square dst) const noexcept |
| Generates a list of legal queen moves with a known destination square. May be capturing. | |
| std::size_t | generateMovesForKingAndDest (ShortMoveList &moves, SquareSet srcSqMask, Square dst) const noexcept |
| Generates a list of legal king moves with a known destination square. May be capturing. | |
| std::size_t | generateMovesForShortCastling (ShortMoveList &moves) const noexcept |
| Generates the short castling move in a list, if legal. | |
| std::size_t | generateMovesForLongCastling (ShortMoveList &moves) const noexcept |
| Generates the long castling move in a list, if legal. | |
| std::size_t | generateMoves (MoveList &moves) const noexcept |
| Generates a list of all legal moves for the current position. | |
| std::size_t | getNumberOfLegalMoves () const noexcept |
| Returns the number of legal moves for the current position. This function is mostly useful for calculating the moves in perft leaf positions. | |
| bool | hasLegalMoves () const noexcept |
| Determines whether any legal moves as available in the current position. | |
| void | doMove (Move m) noexcept |
| Applies a move on the current position. The move is assumed to be legal, and it must be from one of the generators. No legality checks are done by this function. | |
| bool | operator== (const ChessBoard &o) const noexcept |
| Comparison operator (equality) | |
Private Member Functions | |
| void | updateCheckersAndPins () noexcept |
| Determines checkers and pinned pieces. | |
| void | validateBoard () |
Validates the board for items that are common for both setBoard() and loadFEN() and sets m_checkers. | |
| void | setCastlingRook (Color c, bool shortCastling, Square sq) noexcept |
| Sets/resets castling rights and the associated rook. | |
| Square & | getCastlingRookRef (Color c, bool shortCastling) noexcept |
| Gets a reference to the castling rights rook for direct read/write access. | |
| void | calculateMasks (const ArrayBoard &board) noexcept |
Calculates bitboard masks for an ArrayBoard object. | |
Static Private Member Functions | |
| static constexpr std::size_t | getCastlingRookIndex (Color c, bool shortCastling) noexcept |
| Returns the array index for a castling rook. | |
Private Attributes | |
| SquareSet | m_occupancyMask { SquareSet::row(0U) | SquareSet::row(1U) | SquareSet::row(6U) | SquareSet::row(7U) } |
| Bit board of occupied squares. | |
| SquareSet | m_turnColorMask { SquareSet::row(0U) | SquareSet::row(1U) } |
Occupied squares that have the same color piece as getTurn() | |
| SquareSet | m_pawns { SquareSet::row(1U) | SquareSet::row(6U) } |
| Pawns. | |
| SquareSet | m_knights |
| Knights. | |
| SquareSet | m_kings { SquareSet::square(Square::E1) | SquareSet::square(Square::E8) } |
| Kings. | |
| SquareSet | m_bishops |
| Bishops and queens. | |
| SquareSet | m_rooks |
| Rooks and queens. | |
| SquareSet | m_checkers { } |
| Squares where there is a checker. | |
| SquareSet | m_pinnedPieces { } |
| Squares with pinned pieces. | |
| const MoveGenFunctions * | m_moveGenFns |
| Move generator functions for this position. | |
| std::uint32_t | m_plyNum { } |
| Current ply number. | |
| std::uint8_t | m_halfMoveClock { } |
| Current half move clock. | |
| Square | m_kingSq { Square::E1 } |
| King in turn. | |
| Square | m_oppKingSq { Square::E8 } |
| King in not turn. | |
| Square | m_epSquare { Square::NONE } |
| En-passant square. | |
| std::array< Square, 4U > | m_castlingRooks { Square::A1, Square::H1, Square::A8, Square::H8 } |
| Castling rooks. | |
The chessboard.
The following move generator variants are provided:
|
noexcept |
Constructor (default)
The default constructor sets the board to the standard starting position.
|
defaultnoexcept |
Constructor (copy)
|
defaultnoexcept |
Constructor (move)
|
defaultnoexcept |
Destructor.
|
privatenoexcept |
Calculates bitboard masks for an ArrayBoard object.
| [in] | board | Chess board in array (mailbox) format |
|
inlinenoexcept |
Determines the status of the position.
This function determines whether there are any legal moves. Then, the status is returned as per the following table:
| Legal moves | getCheckers() | Returned status |
|---|---|---|
| Yes | SquareSet::none() | PositionStatus::NORMAL |
| Yes | Other | PositionStatus::CHECK |
| No | SquareSet::none() | PositionStatus::STALEMATE |
| No | Other | PositionStatus::MATE |
|
noexcept |
Applies a move on the current position. The move is assumed to be legal, and it must be from one of the generators. No legality checks are done by this function.
| [in] | m | Move to apply |
This function does the following:
m_epSquare) as per the movem_kingSqm_halfMoveClock) and ply number (m_plyNum)m_plyNum changes the side to movem_kingSq and m_oppKingSqm_turnColorMask)m_checkers)
|
inlinenoexcept |
Generates a list of all legal moves for the current position.
| [in] | moves | Caller-allocated move list |
|
inlinenoexcept |
Generates a list of legal bishop moves with a known destination square. May be capturing.
| [out] | moves | List of returned moves |
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
|
inlinenoexcept |
Generates a list of legal king moves with a known destination square. May be capturing.
| [out] | moves | List of returned moves |
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
|
inlinenoexcept |
Generates a list of legal knight moves with a known destination square. May be capturing.
| [out] | moves | List of returned moves |
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
|
inlinenoexcept |
Generates the long castling move in a list, if legal.
| [out] | moves | List of returned moves |
|
inlinenoexcept |
Generates a list of legal non-promoting, capturing pawn moves with a known destination square.
| [out] | moves | List of returned moves |
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
|
inlinenoexcept |
Generates a list of legal non-promoting, non-capturing pawn moves with a known destination square.
| [out] | moves | List of returned moves |
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
|
inlinenoexcept |
Generates a list of legal promoting, capturing pawn moves with a known destination square.
| [out] | moves | List of returned moves |
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
| [in] | promo | Promotion piece |
|
inlinenoexcept |
Generates a list of legal promoting, non-capturing pawn moves with a known destination square.
| [out] | moves | List of returned moves |
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
| [in] | promo | Promotion piece |
|
inlinenoexcept |
Generates a list of legal queen moves with a known destination square. May be capturing.
| [out] | moves | List of returned moves |
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
|
inlinenoexcept |
Generates a list of legal rook moves with a known destination square. May be capturing.
| [out] | moves | List of returned moves |
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
|
inlinenoexcept |
Generates the short castling move in a list, if legal.
| [out] | moves | List of returned moves |
|
inlinenoexcept |
Generates a legal bishop move with a known destination square. May be capturing.
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
Move::isIllegal() returns true.
|
inlinenoexcept |
Generates a legal king move with a known destination square. May be capturing.
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
Move::isIllegal() returns true.
|
inlinenoexcept |
Generates a legal knight move with a known destination square. May be capturing.
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
Move::isIllegal() returns true.
|
inlinenoexcept |
Generates a legal long castling move.
Move::isIllegal() returns true.
|
inlinenoexcept |
Generates a legal non-promoting, capturing pawn move with a known destination square.
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
Move::isIllegal() returns true.
|
inlinenoexcept |
Generates a legal non-promoting, non-capturing pawn move with a known destination square.
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
Move::isIllegal() returns true.
|
inlinenoexcept |
Generates a legal promoting, capturing pawn move with a known destination square.
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
| [in] | promo | Promotion piece |
Move::isIllegal() returns true.
|
inlinenoexcept |
Generates a legal promoting, non-capturing pawn move with a known destination square.
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
| [in] | promo | Promotion piece |
Move::isIllegal() returns true.
|
inlinenoexcept |
Generates a legal queen move with a known destination square. May be capturing.
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
Move::isIllegal() returns true.
|
inlinenoexcept |
Generates a legal rook move with a known destination square. May be capturing.
| [in] | srcSqMask | Allowed source squares |
| [in] | dst | Destination square |
Move::isIllegal() returns true.
|
inlinenoexcept |
Generates a legal short castling move.
Move::isIllegal() returns true.
|
noexcept |
Extracts the current position as an ArrayBoard.
| [out] | out_board | Current position |
setBoard()
|
inlinenoexcept |
Returns squares occupied by bishops.
|
inlinenoexcept |
Returns squares occupied by bishops and queens (diagonal sliders)
|
inlinenoexcept |
Shorthand for . getCastlingRook(Color::BLACK, false)
Square::NONE
|
inlinenoexcept |
Returns squares occupied by white pieces (including pawns).
|
inlinenoexcept |
Shorthand for . getCastlingRook(Color::BLACK, true)
Square::NONE
|
inlinenoexcept |
Returns castling rook square if castling rights apply or Square::NONE if no castling rights.
| [in] | c | Side to move |
| [in] | shortCastling | Whether short castling is in question |
Square::NONE if no castling rights.
|
inlinestaticconstexprprivatenoexcept |
Returns the array index for a castling rook.
| [in] | c | Side |
| [in] | shortCastling | Whether short castling is in question |
m_castlingRooks.getCastlingRook()
|
inlineprivatenoexcept |
Gets a reference to the castling rights rook for direct read/write access.
| [in] | c | Side |
| [in] | shortCastling | Whether short castling rights are accessed |
|
inlinenoexcept |
Returns squares occupied by checkers.
|
inlinenoexcept |
Full move counter in plies.
Ply number 0 means white's first move, and ply number 1 means black's first move.
moveNumOfPly(), colorOfPly()
|
inlinenoexcept |
Returns the en-passant square or Square::NONE if en-passant capture is not possible.
Square::NONE if EP-capture is not legal.Square::NONE, at least one EP capture is guaranteed to be legal.Square::NONE.getPinnedPieces() for a discussion on pin handling related to EP captures.
|
inlinenoexcept |
Current half-move clock.
Half-move clock is used to determine 50-move rule and similar draw termination rules.
|
inlinenoexcept |
Returns the square of the king in turn.
|
inlinenoexcept |
Returns the square of the king not in turn.
|
inlinenoexcept |
Returns squares occupied by kings.
|
inlinenoexcept |
Returns squares occupied by knights.
|
inlinenoexcept |
Returns the number of legal moves for the current position. This function is mostly useful for calculating the moves in perft leaf positions.
|
inlinenoexcept |
Returns squares that are occupied by pieces (including pawns).
|
inlinenoexcept |
Returns squares occupied by pawns.
|
inlinenoexcept |
Returns squares that are occupied by pieces (including pawns) that belong to the side to move.
|
inlinenoexcept |
Returns squares occupied by absolutely pinned pieces.
getEpSquare() returns Square::NONE.getEpSquare() returns Square::NONE to signal that EP-capture is not allowed. | Case | Example | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| (1) Diagonally pinned EP-capturable pawn |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (2) Vertically pinned EP-capturable pawn |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (3) Horizontally pinned EP-capturable pawn |
|
getEpSquare()
|
inlinenoexcept |
Returns squares occupied by queens.
|
inlinenoexcept |
Returns squares occupied by rooks.
|
inlinenoexcept |
Returns squares occupied by rooks and queens (horizontal/vertical sliders)
|
noexcept |
Returns the piece and color on a specified square.
| [in] | sq | Square to query |
sq or PieceAndColor::NONE.Returns the piece on a specified square.
| [in] | sq | Square to query |
sq or Piece::NONE.
|
inlinenoexcept |
Returns side to move.
|
inlinenoexcept |
Shorthand for . getCastlingRook(Color::WHITE, false)
Square::NONE
|
inlinenoexcept |
Returns squares occupied by white pieces (including pawns).
|
inlinenoexcept |
Shorthand for . getCastlingRook(Color::WHITE, true)
Square::NONE
|
inlinenoexcept |
Determines whether any legal moves as available in the current position.
|
inlinenoexcept |
Returns whether the king is in check.
| void hoover_chess_utils::pgn_reader::ChessBoard::loadFEN | ( | std::string_view | fen | ) |
Sets the board from FEN.
| [in] | fen | Position described in Forsyth–Edwards Notation (FEN) |
| PgnError(PgnErrorCode::BAD_FEN) | Malformed FEN (e.g., too many rows or columns; bad character; bad castling indicator) |
| PgnError(PgnErrorCode::BAD_FEN) | Pawns on 1st/8th rank |
| PgnError(PgnErrorCode::BAD_FEN) | EP square on wrong rank or not empty; no EP pawn to capture. |
| PgnError(PgnErrorCode::BAD_FEN) | Wrong number of kings |
| PgnError(PgnErrorCode::BAD_FEN) | Opponent king is in check |
The castling indicator may be in FEN, Shredded-FEN, or X-FEN format.
EP capture does not have to be a legal move as long as the EP square is empty and there is a pawn to capture. If case there is no legal EP capture moves (but the other requirements are met), this function resets the EP square.
|
inlinenoexcept |
Loads the starting position.
Resets the board to the regular starting position. Resets also half move clock and ply count.
This is equivalent to assigning a default-constructed ChessBoard.
|
defaultnoexcept |
Move assignment.
|
defaultnoexcept |
Assignment.
|
noexcept |
Comparison operator (equality)
| [in] | o | Another chessboard |
| void hoover_chess_utils::pgn_reader::ChessBoard::printBoard | ( | ) | const |
Prints the current board to stdout. This is intended only for debugging purposes.
| void hoover_chess_utils::pgn_reader::ChessBoard::setBoard | ( | const ArrayBoard & | board, |
| Square | whiteLongCastleRook, | ||
| Square | whiteShortCastleRook, | ||
| Square | blackLongCastleRook, | ||
| Square | blackShortCastleRook, | ||
| Square | epSquare, | ||
| std::uint_fast8_t | halfMoveClock, | ||
| std::uint_fast32_t | plyNum | ||
| ) |
Sets the board from an array board (aka Mailbox)
| [in] | board | Array board containing pieces for squares |
| [in] | whiteLongCastleRook | White long castling rook or Square::NONE if no long castling rights. |
| [in] | whiteShortCastleRook | White short castling rook or Square::NONE if no short castling rights. |
| [in] | blackLongCastleRook | Black long castling rook or Square::NONE if no long castling rights. |
| [in] | blackShortCastleRook | Black short castling rook or Square::NONE if no short castling rights. |
| [in] | epSquare | En-passant square or Square::NONE if en-passant capture is not possible. |
| [in] | halfMoveClock | Half-move clock |
| [in] | plyNum | Ply num. Use makePlyNum() if necessary. |
| PgnError(PgnErrorCode::BAD_FEN) | Invalid input parameter, e.g., bad Square value |
| PgnError(PgnErrorCode::BAD_FEN) | Inconsistent castling rights, e.g., castling rook not found, king not on 1st/8th rank, castling rook on the wrong side |
| PgnError(PgnErrorCode::BAD_FEN) | Pawns on 1st/8th rank |
| PgnError(PgnErrorCode::BAD_FEN) | EP square on wrong rank or not empty; no EP pawn to capture. |
| PgnError(PgnErrorCode::BAD_FEN) | Wrong number of kings |
| PgnError(PgnErrorCode::BAD_FEN) | Opponent king is in check |
| PgnError(PgnErrorCode::BAD_FEN) | Move number overflow (max: 99999) |
EP capture does not have to be a legal move as long as the EP square is empty and there is a pawn to capture. If case there is no legal EP capture moves (but the other requirements are met), this function resets the EP square.
loadFEN() | void hoover_chess_utils::pgn_reader::ChessBoard::setBoard | ( | const BitBoard & | board, |
| Square | whiteLongCastleRook, | ||
| Square | whiteShortCastleRook, | ||
| Square | blackLongCastleRook, | ||
| Square | blackShortCastleRook, | ||
| Square | epSquare, | ||
| std::uint_fast8_t | halfMoveClock, | ||
| std::uint_fast32_t | plyNum | ||
| ) |
Sets the board from SquareSets (bit board)
| [in] | board | Array board containing pieces for squares |
| [in] | whiteLongCastleRook | White long castling rook or Square::NONE if no long castling rights. |
| [in] | whiteShortCastleRook | White short castling rook or Square::NONE if no short castling rights. |
| [in] | blackLongCastleRook | Black long castling rook or Square::NONE if no long castling rights. |
| [in] | blackShortCastleRook | Black short castling rook or Square::NONE if no short castling rights. |
| [in] | epSquare | En-passant square or Square::NONE if en-passant capture is not possible. |
| [in] | halfMoveClock | Half-move clock |
| [in] | plyNum | Ply num. Use makePlyNum() if necessary. |
| PgnError(PgnErrorCode::BAD_FEN) | Invalid input parameter, e.g., bad Square value |
| PgnError(PgnErrorCode::BAD_FEN) | Inconsistent castling rights, e.g., castling rook not found, king not on 1st/8th rank, castling rook on the wrong side |
| PgnError(PgnErrorCode::BAD_FEN) | Pawns on 1st/8th rank |
| PgnError(PgnErrorCode::BAD_FEN) | EP square on wrong rank or not empty; no EP pawn to capture. |
| PgnError(PgnErrorCode::BAD_FEN) | Wrong number of kings |
| PgnError(PgnErrorCode::BAD_FEN) | Opponent king is in check |
| PgnError(PgnErrorCode::BAD_FEN) | Move number overflow (max: 99999) |
| PgnError(PgnErrorCode::BAD_FEN) | More than one piece occupying a square (intersection of per-piece SquareSets is not empty) |
EP capture does not have to be a legal move as long as the EP square is empty and there is a pawn to capture.
loadFEN()
|
inlineprivatenoexcept |
Sets/resets castling rights and the associated rook.
| [in] | c | Side |
| [in] | shortCastling | Whether short castling rights are set/reset |
| [in] | sq | Castling rook or Square::NONE for no castling rights |
|
privatenoexcept |
Determines checkers and pinned pieces.
This function sets m_checkers and m_pinnedPieces.
|
private |
Validates the board for items that are common for both setBoard() and loadFEN() and sets m_checkers.
| PgnError(PgnErrorCode::BAD_FEN) | Validation failed |
|
private |
Bishops and queens.
getBishopsAndQueens()
|
private |
Castling rooks.
The castling rooks are in order:
Rook square Square::NONE signifies no castling right.
getCastlingRookIndex()
|
private |
Squares where there is a checker.
updateCheckersAndPins()
|
private |
En-passant square.
getEpSquare()
|
private |
Current half move clock.
getHalfMoveClock()
|
private |
Kings.
getKings()
|
private |
King in turn.
m_kings, m_turnColorMask
|
private |
|
private |
Move generator functions for this position.
MoveGenType
|
private |
Bit board of occupied squares.
getOccupancyMask()
|
private |
King in not turn.
m_kings, m_turnColorMask
|
private |
Pawns.
getPawns()
|
private |
Squares with pinned pieces.
updateCheckersAndPins()
|
private |
Current ply number.
getCurrentPlyNum()
|
private |
|
private |
Occupied squares that have the same color piece as getTurn()