Chess Engine
C++ chess engine with movegen, bitboards, and Arduino-friendly docs
Loading...
Searching...
No Matches
validate.cpp File Reference
#include <cstdio>
#include "defs.h"
#include "util/setup.h"
#include "validate.h"
Include dependency graph for validate.cpp:

Go to the source code of this file.

Functions

int MoveListOk (const S_MOVELIST *moves, const S_BOARD *board)
 Validates that a move list is within bounds and references valid moves.
int SqIs120 (const int sq)
 Checks if a given square index is within the 120-based range.
int PceValidEmptyOffbrd (const int pce)
 Checks if the given piece code is empty, valid, or OFFBOARD.
int SqOnBoard (const int sq)
 Checks if a given square index refers to a valid on-board square.
int SideValid (const int side)
 Checks if the given side identifier is valid.
int FileRankValid (const int fr)
 Checks if a file or rank index is valid (0–7).
int pieceValueidEmpty (const int pce)
 Checks if the given piece code is either empty or a valid piece.
int pieceValueid (const int pce)
 Checks if the given piece code is a valid piece (non-empty).

Function Documentation

◆ FileRankValid()

int FileRankValid ( const int fr)

Checks if a file or rank index is valid (0–7).

Parameters
frThe file or rank index.
Returns
Non-zero if valid, 0 otherwise.

Definition at line 38 of file validate.cpp.

◆ MoveListOk()

int MoveListOk ( const S_MOVELIST * list,
const S_BOARD * pos )

Validates that a move list is within bounds and references valid moves.

Parameters
listPointer to the move list.
posPointer to the board state.
Returns
Non-zero if the move list is valid, 0 otherwise.

Definition at line 7 of file validate.cpp.

References S_MOVELIST::count, FALSE, FROMSQ, MAXPOSITIONMOVES, S_MOVE::move, S_MOVELIST::moves, S_BOARD::pieces, pieceValueidEmpty(), SqOnBoard(), TOSQ, and TRUE.

Referenced by generateAllCaptures(), and generateAllMoves().

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

◆ PceValidEmptyOffbrd()

int PceValidEmptyOffbrd ( const int pce)

Checks if the given piece code is empty, valid, or OFFBOARD.

Parameters
pcePiece code to check.
Returns
Non-zero if valid, 0 otherwise.

Definition at line 25 of file validate.cpp.

References bK, EMPTY, and OFFBOARD.

Referenced by isSquareAttacked(), and updateListsMaterial().

Here is the caller graph for this function:

◆ pieceValueid()

int pieceValueid ( const int pce)

Checks if the given piece code is a valid piece (non-empty).

Parameters
pcePiece code to check.
Returns
Non-zero if valid, 0 otherwise.

Definition at line 46 of file validate.cpp.

References bK, and wP.

Referenced by AddCaptureMove(), AddPiece(), ClearPiece(), generateAllCaptures(), generateAllMoves(), makeMove(), MovePiece(), and takeMove().

Here is the caller graph for this function:

◆ pieceValueidEmpty()

int pieceValueidEmpty ( const int pce)

Checks if the given piece code is either empty or a valid piece.

Parameters
pcePiece code to check.
Returns
Non-zero if valid, 0 otherwise.

Definition at line 42 of file validate.cpp.

References bK, and EMPTY.

Referenced by AddBlackPawnCapMove(), AddWhitePawnCapMove(), and MoveListOk().

Here is the caller graph for this function:

◆ SideValid()

int SideValid ( const int side)

Checks if the given side identifier is valid.

Parameters
sideSide value to check (WHITE or BLACK).
Returns
Non-zero if valid, 0 otherwise.

Definition at line 34 of file validate.cpp.

References BLACK, and WHITE.

Referenced by AddPiece(), ClearPiece(), isSquareAttacked(), makeMove(), MovePiece(), and updateListsMaterial().

Here is the caller graph for this function:

◆ SqIs120()

int SqIs120 ( const int sq)

Checks if a given square index is within the 120-based range.

Parameters
sqThe square index to check.
Returns
Non-zero if valid, 0 otherwise.

Definition at line 21 of file validate.cpp.

References BRD_SQ_NUM.

Referenced by isSquareAttacked().

Here is the caller graph for this function:

◆ SqOnBoard()

int SqOnBoard ( const int sq)

Checks if a given square index refers to a valid on-board square.

Parameters
sqThe 120-based square index.
Returns
Non-zero if valid, 0 otherwise.

Definition at line 29 of file validate.cpp.

References BRD_SQ_NUM, fileIndex120, and OFFBOARD.

Referenced by AddBlackPawnCapMove(), AddBlackPawnMove(), AddCaptureMove(), AddEnPassantMove(), AddPiece(), AddQuietMove(), AddWhitePawnCapMove(), AddWhitePawnMove(), ClearPiece(), generateAllCaptures(), generateAllMoves(), generatePositionKeys(), initSquareIndexMaps(), isPieceListValid(), isSquareAttacked(), makeMove(), MoveListOk(), MovePiece(), parseMoveString(), and takeMove().

Here is the caller graph for this function: