thomasahle/sunfish
Sunfish: a Python Chess Engine in 111 lines of code
What it solves
Sunfish is a minimalist chess engine designed to be simple, readable, and strong enough to be playable. It provides a compact codebase that serves as a learning platform for developers to experiment with search algorithms, evaluation functions, and deep learning in chess programming.
How it works
The engine is written in Python and uses the MTD-bi (C*) search algorithm. It employs classic chess engine techniques, such as Piece Square Tables for an efficiently updatable evaluation function and standard Python collections for data structures. A specialized NNUE (Efficiently Updatable Neural Network) version is also available, which packs a trained neural residual into a single Python integer to maintain a tiny footprint while increasing playing strength.
Who it’s for
It is intended for developers, students, and chess engine enthusiasts who want a readable reference implementation of a chess engine or a base for creating their own derivatives.
Highlights
- Ultra-compact: The core engine is approximately 152 lines of code.
- UCI Compatible: Works with standard chess GUIs like Arena, Cute Chess, and PyChess.
- NNUE Support: Includes a neural-network-based evaluation version that remains only a few kilobytes in size.
- Extensible: Designed specifically as a platform for experimenting with parallel search, deep learning, and evaluation tuning.
Related
- Project
- Project
- Project
- Project
- Project