Chess Engine Architecture and Layering
Overview
This chess engine is built as a layered library that separates physical board representation, move generation, legality filtering, and public API orchestration. It supports both standard 8x8 chess and a four-player 14x14 variant using a unified core.
Layering Model
flowchart TB
PublicAPI[Public API: Chess class]
SAN[Notation: SAN and PGN]
Legality[Legality: Check and Pins]
MoveGen[Move Generation: Pseudo-legal]
Board[Board: Pieces and Squares]
PublicAPI --> SAN
PublicAPI --> Legality
PublicAPI --> Board
SAN --> Legality
Legality --> MoveGen
MoveGen --> Board
- Board Layer: Low-level square and piece representation.
- Move Generation Layer: Produces every possible move regardless of king safety.
- Legality Layer: Filters out moves that leave the king in check.
- Notation Layer: Converts between internal move formats and human-readable text.
- Orchestration Layer: Manages game state, history, and multi-player logic.
Variant Support
The core is designed to be variant-agnostic. Each variant defines:
- Board dimensions
- Starting positions
- Piece movement rules
- Win/loss conditions
Currently, it supports:
- Standard: The classic 8x8 game.
- 4-Player: A 14x14 board with specialized geometry and elimination rules.