Chess Engine
C++ chess engine with movegen, bitboards, and Arduino-friendly docs
Loading...
Searching...
No Matches
board.h File Reference
#include "../defs.h"
#include "../test./validate.h"
Include dependency graph for board.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool isPieceListValid (const S_BOARD *pos)
 Validate that piece list array is consistent with board state.
bool isBoardStateValid (const S_BOARD *pos)
 Performs a full internal consistency check of the board state.
void updateListsMaterial (S_BOARD *pos)
 Update piece lists, material counts, and pawn bitboards from scratch.
int loadFEN (char *fen, S_BOARD *pos)
 Parse a FEN string into the given board state.
void resetBoardState (S_BOARD *pos)
 Reset board to empty state.
void printBoardState (const S_BOARD *pos)
 Print the board to stdout in a human-readable format.
void mirrorBoardPosition (S_BOARD *pos)
 Flip the board vertically, swapping colors and positions.

Function Documentation

◆ isBoardStateValid()

bool isBoardStateValid ( const S_BOARD * pos)
extern

Performs a full internal consistency check of the board state.

Parameters
posPointer to board state.
Returns
TRUE if board is valid, FALSE otherwise.

Definition at line 28 of file board.cpp.

References ASSERT, S_BOARD::bigPce, bK, BLACK, BOTH, bP, S_BOARD::castlePerm, CNT, S_BOARD::enPas, generatePositionKeys(), isBigPiece, isMajorPiece, isMinorPiece, isPieceListValid(), S_BOARD::KingSq, S_BOARD::majPce, S_BOARD::material, S_BOARD::minPce, NO_SQ, S_BOARD::pawns, S_BOARD::pceNum, pieceColor, S_BOARD::pieces, pieceValue, S_BOARD::pList, POP, S_BOARD::posKey, RANK_3, RANK_6, rankIndex120, S_BOARD::side, SQ120, TRUE, WHITE, wK, and wP.

Referenced by AddBlackPawnCapMove(), AddBlackPawnMove(), AddCaptureMove(), AddEnPassantMove(), AddQuietMove(), AddWhitePawnCapMove(), AddWhitePawnMove(), ClearPiece(), generateAllCaptures(), generateAllMoves(), isSquareAttacked(), makeMove(), makeNullMove(), mirrorBoardPosition(), parseMoveString(), Perft(), PerftTest(), takeMove(), and takeNullMove().

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

◆ isPieceListValid()

bool isPieceListValid ( const S_BOARD * pos)
extern

Validate that piece list array is consistent with board state.

Parameters
posPointer to board state.
Returns
TRUE if list is valid, FALSE otherwise.

Definition at line 12 of file board.cpp.

References bK, FALSE, S_BOARD::pceNum, S_BOARD::pList, SqOnBoard(), wK, and wP.

Referenced by isBoardStateValid().

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

◆ loadFEN()

int loadFEN ( char * fen,
S_BOARD * pos )
extern

Parse a FEN string into the given board state.

Parameters
fenFEN string.
posPointer to board state.
Returns
0 on success, -1 on failure.

Definition at line 146 of file board.cpp.

References ASSERT, bB, bK, BKCA, BLACK, bN, bP, bQ, BQCA, bR, S_BOARD::castlePerm, EMPTY, S_BOARD::enPas, FILE_A, FILE_H, FR2SQ, generatePositionKeys(), S_BOARD::pieces, S_BOARD::posKey, RANK_1, RANK_8, resetBoardState(), S_BOARD::side, SQ120, updateListsMaterial(), wB, WHITE, wK, WKCA, wN, wP, wQ, WQCA, and wR.

Referenced by main().

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

◆ mirrorBoardPosition()

void mirrorBoardPosition ( S_BOARD * pos)
extern

Flip the board vertically, swapping colors and positions.

Parameters
posPointer to board state.

Definition at line 301 of file board.cpp.

References ASSERT, bB, bK, BKCA, bN, bP, bQ, BQCA, bR, S_BOARD::castlePerm, EMPTY, S_BOARD::enPas, generatePositionKeys(), isBoardStateValid(), Mirror64, NO_SQ, S_BOARD::pieces, S_BOARD::posKey, resetBoardState(), S_BOARD::side, SQ120, SQ64, updateListsMaterial(), wB, wK, WKCA, wN, wP, wQ, WQCA, and wR.

Here is the call graph for this function:

◆ printBoardState()

void printBoardState ( const S_BOARD * pos)
extern

Print the board to stdout in a human-readable format.

Parameters
posPointer to board state.

Definition at line 272 of file board.cpp.

References BKCA, BQCA, S_BOARD::castlePerm, S_BOARD::enPas, FILE_A, FILE_H, FR2SQ, S_BOARD::pieces, pieceToCharacter, S_BOARD::posKey, RANK_1, RANK_8, S_BOARD::side, SideChar, WKCA, and WQCA.

Referenced by main(), and PerftTest().

Here is the caller graph for this function:

◆ resetBoardState()

void resetBoardState ( S_BOARD * pos)
extern

Reset board to empty state.

Parameters
posPointer to board state.

Definition at line 236 of file board.cpp.

References S_BOARD::bigPce, BLACK, BOTH, BRD_SQ_NUM, S_BOARD::castlePerm, EMPTY, S_BOARD::enPas, S_BOARD::fiftyMove, S_BOARD::hisPly, S_BOARD::KingSq, S_BOARD::majPce, S_BOARD::material, S_BOARD::minPce, NO_SQ, OFFBOARD, S_BOARD::pawns, S_BOARD::pceNum, S_BOARD::pieces, S_BOARD::ply, S_BOARD::posKey, S_BOARD::side, SQ120, and WHITE.

Referenced by loadFEN(), and mirrorBoardPosition().

Here is the caller graph for this function:

◆ updateListsMaterial()

void updateListsMaterial ( S_BOARD * pos)
extern

Update piece lists, material counts, and pawn bitboards from scratch.

Parameters
posPointer to board state.

Definition at line 112 of file board.cpp.

References ASSERT, S_BOARD::bigPce, bK, BLACK, BOTH, bP, BRD_SQ_NUM, EMPTY, isBigPiece, isMajorPiece, isMinorPiece, S_BOARD::KingSq, S_BOARD::majPce, S_BOARD::material, S_BOARD::minPce, OFFBOARD, S_BOARD::pawns, S_BOARD::pceNum, PceValidEmptyOffbrd(), pieceColor, S_BOARD::pieces, pieceValue, S_BOARD::pList, SETBIT, SideValid(), SQ64, TRUE, WHITE, wK, and wP.

Referenced by loadFEN(), and mirrorBoardPosition().

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