Minimal chess engine in pure Python with:
- Correct move generation (0x88 board; includes castling, en passant, promotions)
- Alpha-beta search (negamax + quiescence) with iterative deepening
- UCI protocol support (so you can play it in any GUI / vs other engines)
- A small match runner to estimate Elo difference from game results
python3 -m chesspyYou can then connect it from a UCI-compatible GUI (Arena, CuteChess GUI, Banksia, etc.).
Start position perft:
python3 tools/perft.py 4This plays games between 2 UCI engines and prints the score + an approximate Elo difference.
Example: chesspy vs Stockfish at a limited strength:
python3 tools/match.py \
--games 20 \
--movetime-ms 250 \
--name-a chesspy \
--name-b sf1320 \
--engine-a "python3 -m chesspy" \
--engine-b "stockfish" \
--b-opt UCI_LimitStrength=true \
--b-opt UCI_Elo=1320Notes:
- The reported number is Elo diff (A - B) computed from the match score.
- To get an approximate absolute Elo, repeat matches for several
UCI_Elovalues and find where the score is ~50%. - Elo is not portable: it depends heavily on time control, hardware, and opponent settings.
- For more reliable estimates, use an opening suite and play in paired mode (same opening twice, colors swapped):
python3 tools/match.py \
--games 50 \
--movetime-ms 250 \
--openings openings.example.txt \
--openings-pairsopenings.example.txt format: one opening per line, either a FEN/EPD position or a list of UCI moves from startpos.
To save games as PGN:
python3 tools/match.py \
--games 10 \
--movetime-ms 250 \
--openings openings.example.txt \
--pgn /tmp/match.pgnTo run a multi-level/multi-seed rating experiment and fit an absolute Elo estimate:
python3 tools/rating.py \
--levels 1700,1800,1900 \
--seeds 1,2,3 \
--games 100 \
--movetime-ms 250 \
--openings openings.example.txt \
--openings-pairs \
--engine-a "python3 -m chesspy" \
--engine-b stockfish \
--json-out /tmp/rating-report.json