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

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby Chess Engine

Minimal UCI chess engine in pure Ruby, with scripts to run engine-vs-engine matches and estimate Elo difference.

What is included

  • 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.

Quick start

ruby -Ilib bin/ruby_chess_engine

UCI smoke test:

printf "uci\nisready\nquit\n" | ruby -Ilib bin/ruby_chess_engine

Run tests:

ruby -Itest test/test_position.rb
ruby -Itest test/test_perft.rb
ruby -Itest test/test_uci.rb

Match and Elo workflow

1. Run matches

Example: 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.json

The 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

2. Convert to absolute Elo (optional)

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 1350

The JSON summary then includes estimated_elo for engine A.

3. Direct Elo computation from W/D/L

ruby scripts/estimate_elo.rb --wins 42 --draws 18 --losses 40 --opponent-elo 1500

Practical rating advice

  • Use at least 100-200 games 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: UseNullMove and UseLMR.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages