Minimal UCI chess engine in pure Ruby, with scripts to run engine-vs-engine matches and estimate Elo difference.
bin/ruby_chess_engine: UCI engine entrypoint.lib/ruby_chess_engine/*: board representation, legal move generation, evaluation, and alpha-beta search.scripts/run_matches.rb: plays many games between two UCI engines and estimates rating difference.scripts/estimate_elo.rb: computes Elo difference directly from W/D/L counts.test/*: Minitest suite with legality/perft/UCI smoke checks.- Built-in opening book for early mainline development from
startpos.
ruby -Ilib bin/ruby_chess_engineUCI smoke test:
printf "uci\nisready\nquit\n" | ruby -Ilib bin/ruby_chess_engineRun tests:
ruby -Itest test/test_position.rb
ruby -Itest test/test_perft.rb
ruby -Itest test/test_uci.rbExample: your engine vs Stockfish at a limited skill level.
ruby scripts/run_matches.rb \
--engine-a "ruby bin/ruby_chess_engine" \
--engine-b "stockfish" \
--engine-b-option "Skill Level=3" \
--games 100 \
--movetime-ms 100 \
--out artifacts/skill3_100g.jsonThe script alternates colors automatically and writes:
- game-by-game results
- wins/draws/losses
- score
- Elo difference (
engine_a - engine_b) with an approximate 95% confidence interval
If you assume an Elo for the opponent:
ruby scripts/run_matches.rb \
--engine-a "ruby bin/ruby_chess_engine" \
--engine-b "stockfish" \
--engine-b-option "Skill Level=3" \
--games 200 \
--movetime-ms 100 \
--opponent-elo 1350The JSON summary then includes estimated_elo for engine A.
ruby scripts/estimate_elo.rb --wins 42 --draws 18 --losses 40 --opponent-elo 1500- Use at least
100-200games per rating point estimate. - Keep time controls identical between runs.
- Compare against multiple nearby opponents (for example Stockfish
Skill Level=1..6) and interpolate. - Re-run with a different opening seed/book if you add one later.
- For very fast controls (for example
10-30ms), try--engine-a-option "MaxDepth=3"to avoid over-searching and timing noise. - Search tuning knobs are available via UCI options:
UseNullMoveandUseLMR.