Stateless helpers used by Position move validation. More...
Functions | |
| bool | valid_king (squareT sqFrom, squareT sqTo) |
| Returns true when the two squares are a king move apart. | |
| bool | valid_knight (squareT sqFrom, squareT sqTo) |
| Returns true when the two squares form a knight move. | |
| int | valid_slider (squareT sqFrom, squareT sqTo, pieceT pieceType) |
Returns the slider step from sqFrom to sqTo. | |
| bool | attack_pawn (squareT sqFrom, squareT sqTo, colorT pieceCol) |
Returns true when a pawn of pieceCol attacks sqTo from sqFrom. | |
| template<typename TFunc > | |
| bool | attack_slider (squareT sqFrom, squareT sqTo, pieceT pieceType, TFunc isOccupied) |
| Returns true when a slider attacks along an unobstructed ray. | |
| template<typename TFunc > | |
| bool | attack (squareT sqFrom, squareT sqTo, pieceT pieceCol, pieceT pieceType, TFunc isOccupied) |
| Validates an attack move. | |
| template<typename TFunc > | |
| bool | pseudo_advance_pawn (squareT sqFrom, squareT sqTo, colorT pieceCol, TFunc isOccupied) |
| Validates a non-capturing pawn advance. | |
| template<typename TFunc > | |
| bool | pseudo (squareT sqFrom, squareT sqTo, colorT pieceCol, pieceT pieceType, TFunc isOccupied) |
| Validates pseudo-legal movement using piece geometry and occupancy. | |
| template<typename TFunc > | |
| std::pair< pieceT, squareT > | opens_ray (squareT sqFrom, squareT sqTo, squareT sqRay, TFunc isOccupied) |
| Finds a possible discovered pin caused by moving from a ray. | |
| bool | blocks_ray (squareT sqFrom, squareT sqTo, squareT sqBlock) |
Tests whether sqBlock lies between two ray-aligned squares. | |
Variables | |
| constexpr int | NSQUARES = 8 |
| constexpr int | kWPHomeRank = 1 |
| constexpr int | kBPHomeRank = NSQUARES - 2 |
Stateless helpers used by Position move validation.
These helpers separate chess movement into four levels:
| bool scid::core::move_predicates::attack | ( | squareT | sqFrom, |
| squareT | sqTo, | ||
| pieceT | pieceCol, | ||
| pieceT | pieceType, | ||
| TFunc | isOccupied | ||
| ) |
Validates an attack move.
| sqFrom | square of the attacking piece. |
| sqTo | square being attacked. |
| pieceCol | colour of the attacking piece. |
| pieceType | type of the attacking piece. |
| isOccupied | callable returning true when an intermediate square is occupied. It is not called for sqFrom or sqTo, so it can describe either the pre-move or post-move occupancy of those endpoint squares. |
sqTo from sqFrom. | bool scid::core::move_predicates::attack_slider | ( | squareT | sqFrom, |
| squareT | sqTo, | ||
| pieceT | pieceType, | ||
| TFunc | isOccupied | ||
| ) |
Returns true when a slider attacks along an unobstructed ray.
isOccupied is called only for squares strictly between sqFrom and sqTo.
|
inline |
Tests whether sqBlock lies between two ray-aligned squares.
sqBlock would block a queen ray from sqFrom to sqTo.
|
inline |
Finds a possible discovered pin caused by moving from a ray.
Given a pseudo-legal move, this returns the kind and square of the first piece that may pin the mover to sqRay, usually the mover's king square.
| sqFrom | origin square of the pseudo-legal move. |
| sqTo | destination square of the pseudo-legal move. |
| sqRay | square through which the projected ray passes. |
| isOccupied | callable returning true when a square is occupied. |
| bool scid::core::move_predicates::pseudo | ( | squareT | sqFrom, |
| squareT | sqTo, | ||
| colorT | pieceCol, | ||
| pieceT | pieceType, | ||
| TFunc | isOccupied | ||
| ) |
Validates pseudo-legal movement using piece geometry and occupancy.
This covers attacks and non-capturing pawn advances. Castling is handled by Position because castling rights, rook identity, and attacked transit squares require full position state.
|
inline |
Validates a non-capturing pawn advance.
Single and home-rank double advances are accepted when every traversed square is empty according to isOccupied.