#include <piece_tracker.h>
|
| | PieceTracker () |
| void | clear () |
| void | initStartingPosition () |
| void | initFromReverseMap (const int squareForSlot[2][16]) |
| void | applyMove (int from, int to, bool isWhite, bool isCapture, int capturedSquare=-1, bool capturedIsWhite=false) |
| void | applyRookCastle (int rookFrom, int rookTo, bool isWhite) |
| void | undoMove (int from, int to, bool isWhite, bool isCapture, int capturedSquare, bool capturedIsWhite, int capturedSlot) |
| void | undoRookCastle (int rookFrom, int rookTo, bool isWhite) |
| int | getSlotAt (int square) const |
| int | getSquareForSlot (bool isWhite, int slot) const |
| bool | isPieceAlive (bool isWhite, int slot) const |
| void | print () const |
◆ PieceTracker()
| PieceTracker::PieceTracker |
( |
| ) |
|
|
inline |
◆ clear()
| void PieceTracker::clear |
( |
| ) |
|
|
inline |
Clear all tracking (all squares empty, all pieces unplaced).
◆ initStartingPosition()
| void PieceTracker::initStartingPosition |
( |
| ) |
|
|
inline |
Initialize for the standard starting position. White pieces on ranks 1-2 (rows 6-7, squares 48-63). Black pieces on ranks 7-8 (rows 0-1, squares 0-15).
◆ initFromReverseMap()
| void PieceTracker::initFromReverseMap |
( |
const int | squareForSlot[2][16] | ) |
|
|
inline |
Seed the tracker from a reverse map (per side, per slot -> square, or -1 for a piece in storage). This is how a review or "play from here" sets identity to a known past snapshot rather than the standard start (review-docs §6.5).
◆ applyMove()
| void PieceTracker::applyMove |
( |
int | from, |
|
|
int | to, |
|
|
bool | isWhite, |
|
|
bool | isCapture, |
|
|
int | capturedSquare = -1, |
|
|
bool | capturedIsWhite = false ) |
|
inline |
Update tracking after a move.
- Parameters
-
| from | Source square (0-63) |
| to | Target square (0-63) |
| isWhite | True if the moving piece is white |
| isCapture | True if this move captures a piece |
| capturedSquare | The square where the captured piece was (usually == to, except for en passant) |
| capturedIsWhite | True if the captured piece is white |
◆ applyRookCastle()
| void PieceTracker::applyRookCastle |
( |
int | rookFrom, |
|
|
int | rookTo, |
|
|
bool | isWhite ) |
|
inline |
Update tracking for castling rook movement. Call this in addition to applyMove for the king.
- Parameters
-
| rookFrom | Rook's source square |
| rookTo | Rook's destination square |
| isWhite | True if white is castling |
◆ undoMove()
| void PieceTracker::undoMove |
( |
int | from, |
|
|
int | to, |
|
|
bool | isWhite, |
|
|
bool | isCapture, |
|
|
int | capturedSquare, |
|
|
bool | capturedIsWhite, |
|
|
int | capturedSlot ) |
|
inline |
Update tracking for pawn promotion. The piece identity stays the same — a promoted pawn is still tracked as SLOT_Px. The physical piece doesn't change (the system uses the same magnet), and when captured, the promoted piece goes back to its pawn slot in storage.
No special handling needed — applyMove already preserves the slot identity through the move. This method exists only for documentation clarity. Reverse a previously-applied move (physical review, review-docs PLAN §6.2). The exact inverse of applyMove: the moving piece goes back to->from, and a captured piece is restored to its square from the storage slot it occupies.
The captured slot cannot be recovered from the post-move tracker (the piece is no longer on any square), so the caller — the ReviewSession replaying the game — supplies it. capturedSlot is SLOT_NONE for a non-capture.
- Parameters
-
| capturedSquare | Where the captured piece was (==to, except en passant) |
| capturedSlot | The StartingSlot the captured piece was standing in |
◆ undoRookCastle()
| void PieceTracker::undoRookCastle |
( |
int | rookFrom, |
|
|
int | rookTo, |
|
|
bool | isWhite ) |
|
inline |
Reverse a castling rook movement (call alongside undoMove for the king).
◆ getSlotAt()
| int PieceTracker::getSlotAt |
( |
int | square | ) |
const |
|
inline |
Get the StartingSlot of the piece on a given square.
- Returns
- StartingSlot (0-15), SLOT_NONE if empty, SLOT_UNKNOWN if unknown
◆ getSquareForSlot()
| int PieceTracker::getSquareForSlot |
( |
bool | isWhite, |
|
|
int | slot ) const |
|
inline |
Get the current square of a piece identified by its starting slot.
- Parameters
-
| isWhite | True for white pieces, false for black |
| slot | The StartingSlot (0-15) |
- Returns
- Square index (0-63), or -1 if the piece has been captured
◆ isPieceAlive()
| bool PieceTracker::isPieceAlive |
( |
bool | isWhite, |
|
|
int | slot ) const |
|
inline |
Check if a piece (by starting slot) is still on the board.
◆ print()
| void PieceTracker::print |
( |
| ) |
const |
|
inline |
Print the current piece identity map (for debugging).
The documentation for this class was generated from the following file: