Starter workspace to build a chess engine in WhyML (Why3), then evaluate it with engine-vs-engine matches and an Elo estimate.
- A minimal WhyML engine core in
src/whyml/engine.mlw:- board representation
- pseudo-legal move generation (no castling / en-passant / check legality filtering yet)
- material evaluation
- alpha-beta negamax search
- A benchmark pipeline in Python:
scripts/run_elo_benchmark.pyscripts/estimate_elo_from_pgn.pyscripts/elo_utils.py
- A runnable UCI engine path from WhyML:
- extraction + build script:
scripts/build_whyml_uci.sh - OCaml UCI adapter:
src/uci_ocaml/main.ml - Dune config:
dune-project,src/uci_ocaml/dune
- extraction + build script:
- The benchmark pipeline runs matches with
cutechess-cliand estimates Elo against Stockfish configured withUCI_LimitStrength=trueandUCI_Elo=<level>.
This WhyML engine is intentionally small and not tournament-ready yet:
- no castling
- no en-passant
- no check/checkmate legality filter
- promotion currently defaults to queen
- no transposition table, no quiescence, no advanced evaluation
It is a solid base to iterate with verification and incremental strength improvements.
- Python 3.10+
cutechess-clistockfish- Why3 toolchain (for the WhyML part)
On this machine, cutechess-cli and stockfish are available, while why3 must be installed.
Example: run a short sanity check where a weakened Stockfish (as placeholder for your future WhyML engine UCI binary) plays against nearby Stockfish Elo levels.
python3 scripts/run_elo_benchmark.py \
--engine-name test-sf1300 \
--engine-cmd /opt/homebrew/bin/stockfish \
--engine-option UCI_LimitStrength=true \
--engine-option UCI_Elo=1300 \
--levels 1320 \
--games-per-level 2 \
--tc st=0.1 \
--tag smokeOutputs are written under results/:
- PGN files for each level
*-summary.json*-summary.md
To estimate Elo from an existing PGN:
python3 scripts/estimate_elo_from_pgn.py \
--pgn results/some-match.pgn \
--engine-name whyml-engine \
--opponent-rating 1400Once you have a UCI executable for your WhyML-based engine:
python3 scripts/run_elo_benchmark.py \
--engine-name whyml-engine \
--engine-cmd /absolute/path/to/your_uci_engine \
--levels 1320,1500,1700 \
--games-per-level 40 \
--tc 40/15+0.05 \
--tag whyml-v1Note: Stockfish 18 exposes UCI_Elo bounds 1320..3190; lower requested levels are clamped.
For less optimistic and slower runs, disable adjudication shortcuts:
python3 scripts/run_elo_benchmark.py \
--engine-name whyml-engine \
--engine-cmd /absolute/path/to/your_uci_engine \
--levels 1320,1400 \
--games-per-level 40 \
--tc 3+0.05 \
--concurrency 1 \
--disable-draw-adjudication \
--disable-resign-adjudication \
--tag whyml-strictBuild executable:
make build-uciRun UCI smoke test:
make uci-smokeQuick Elo run:
make elo-quickBinary path:
build/whyml_uci_engine
- Model and verify core invariants in WhyML (
src/whyml/engine.mlwsplit into modules later). - Extract to OCaml (
why3 extract) for execution performance. - Build a thin OCaml UCI adapter that:
- translates UCI position/move strings into your extracted engine state,
- calls search,
- prints
bestmove ....
- Benchmark with
scripts/run_elo_benchmark.py.
- Add full legal move generation and check detection first.
- Add perft tests before deepening search.
- Add iterative deepening + aspiration windows + TT.
- Add simple opening suite and fixed random seed for reproducible Elo runs.