Chess Class Orchestration
State Management
The Chess class uses a linked-list of GameState nodes to manage history. This allows for constant-time undo() and redo() operations while maintaining the full state for repetition detection.
Member variables
| Variable |
Description |
_head |
The tail of the linked list (current state). |
_board |
Instance of the current Board. |
p / q / r … |
Memoized results for performance. |
Methods Overview
| Category |
Methods |
| Query |
turn(), moves(), get(), history(), fen(), ascii() |
| Logic |
move(), undo(), load(), reset(), clear() |
| Validation |
inCheck(), isGameOver(), isDraw() |
Move Logic flow
- Normalize: Input is converted to a move object (from-to-promotion).
- Validate: Check against
moveGen and legality.
- Apply:
makeMove updates the board and spawns a new GameState node.
- Clean up:
Zobrist hash is updated for the new state.