Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

chess-py

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

Run the engine (UCI)

python3 -m chesspy

You can then connect it from a UCI-compatible GUI (Arena, CuteChess GUI, Banksia, etc.).

Quick correctness check (perft)

Start position perft:

python3 tools/perft.py 4

Play matches and estimate Elo

This 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=1320

Notes:

  • The reported number is Elo diff (A - B) computed from the match score.
  • To get an approximate absolute Elo, repeat matches for several UCI_Elo values 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-pairs

openings.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.pgn

To 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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages