How empa2/py-chess works
PyChess is a UCI chess engine. Its principal workflow is a GUI or other UCI client sending position and search commands, the engine searching the position, and returning a best move. Internally, search relies on board representation, move generation and make/unmake, hashing, draw rules, move ordering, and NNUE evaluation. The README documents these capabilities; edges into internals are limited to relationships supported by the excerpts or source index, so some implementation details remain unconnected.
Main entry points: search.py Iterative search · movegen.py Move generation · see.py Exchange evaluation · nnue.py NNUE evaluator
Components 18
UCI interface
- UCI protocol
uci.py
Position and moves
- Board and FEN
engine/board.py - Bitboard utilities
engine/bitboard.py - Attack tables
engine/attacks.py - Magic attacks
engine/magic.py - Move encoding
engine/move.py - Move generation
engine/movegen.py - Make and unmake
engine/make_move.py
Search and evaluation
- Iterative search
engine/search.py - NNUE evaluator
engine/nnue.py - NNUE accumulator
engine/nnue_accumulator.py - NNUE network
nets/nnue_128_v1.bin - Draw rules
engine/rules.py
Search support
- Exchange evaluation
engine/see.py - Zobrist hashing
engine/zobrist.py - Transposition table
engine/tt.py - Search statistics
engine/search_stats.py
Other components
- UCI client
Connections 20
- UCI client → UCI protocol: sends commands
README.md - UCI protocol → Iterative search: starts search
README.md - Iterative search → Board and FEN: uses position
engine/search.py - Iterative search → Move generation: generates moves
engine/search.py - Iterative search → Make and unmake: plays moves
engine/search.py - Iterative search → NNUE evaluator: evaluates positions
engine/search.py - Iterative search → NNUE accumulator: updates evaluation
engine/search.py - Iterative search → Draw rules: checks draws
engine/search.py - Iterative search → Exchange evaluation: orders captures
engine/search.py - Iterative search → Zobrist hashing: tracks positions
engine/search.py - Iterative search → Transposition table: probes table
engine/search.py - Iterative search → Search statistics: records metrics
engine/search.py - NNUE evaluator → NNUE network: loads weights
- NNUE accumulator → NNUE evaluator: uses evaluator
engine/nnue_accumulator.py - Move generation → Move encoding: encodes moves
engine/movegen.py - Move generation → Attack tables: uses attack tables
engine/movegen.py - Move generation → Magic attacks: queries sliders
engine/movegen.py - Exchange evaluation → Attack tables: reads attacks
engine/see.py - Exchange evaluation → Magic attacks: queries sliders
engine/see.py - Board and FEN → Bitboard utilities: uses bitboards