Guides ·
Building a 3000 Elo Chess Engine in Rust and WebAssembly
The engine behind calichess.cc was written from scratch in Rust, measured at about 3039 Elo on the CCRL Blitz scale, and compiled to WebAssembly so it runs in a browser tab. This is how, with the numbers.
The rule: games decide, not intuition
Chess engines are full of ideas that sound good and make the engine weaker. So each change played the previous version in a sequential probability ratio test (SPRT): keep playing games until the statistics can say "better" or "not better" with set confidence.

Measuring strength honestly
Beating your own older versions only says you improved, not how strong you are. For that, the engine played 120 games against each of five versions of Stash, an open-source engine with known ratings.
| Opponent | Its CCRL rating | Rating our result implies |
|---|---|---|
| Stash 21 | 2713 | 3072 |
| Stash 25 | 2932 | 3008 |
| Stash 28 | 3082 | 3059 |
| Stash 31 | 3207 | 3083 |
| Stash 34 | 3314 | 2948 |
| All 600 games | ~3039 |
Speed: same thinking, less time
The biggest single gain did not change what the engine thinks at all. It searched the exact same tree of moves, node for node, about 1.9 times faster: hopeless moves are now thrown out before they are played on the board, memory is reused instead of cleared at every step, and scores already computed are kept. A fixed benchmark visited exactly 6,891,892 positions before and after, which proves the thinking did not change. That alone was worth about 117 Elo.
| Position (5 s each, one thread, Apple M4) | Depth | Positions / s |
|---|---|---|
| Starting position | 19 | 2.28 M |
| Closed d4 middlegame | 20 | 2.40 M |
| Kiwipete | 20 | 1.86 M |
| Sicilian middlegame | 19 | 2.30 M |
| Bishop endgame | 31 | 3.34 M |
| Italian middlegame | 23 | 2.74 M |
Into the browser
Rust compiles to WebAssembly with no code changes. The engine runs in a background thread (a Web Worker), so the board never freezes while it thinks. The download is 191 KB compressed. In the browser it reaches 1.0 to 1.5 million positions per second, and the move finder answers at depth 9 to 10 in about 0.2 seconds.
Nothing leaves the machine: the build fails if any network call appears in the engine, the app or the build scripts.
What did not work
| Idea | Result |
|---|---|
| Singular extensions | −8 ± 16 |
| Evaluation re-trained on deep engine scores of Lichess positions | −159 ± 43 |
| Evaluation re-trained on its own search scores | −21 ± 17 |
| An evaluation cache | +2% speed, inside the noise |
One bug taught the biggest lesson: adding "skip captures that lose material" first cost 80 Elo. The idea was right; the function that judges a trade had a bug. After fixing it, the same idea gained +60.
The full write-up, with every commit and test, is in the case study on GitHub.
Questions
How was the Elo measured?
600 games at 8 seconds plus 0.08 s per move against five versions of the open-source engine Stash, whose CCRL ratings are known. The result was about 3039 CCRL Blitz, with a 95% range of 3007 to 3071.
Why Rust?
It is as fast as C for this kind of work, it catches many bugs before the program runs, and it compiles to WebAssembly without changes.
How fast is it in the browser?
1.0 to 1.5 million positions per second. Native, on an Apple M4, it does 1.9 to 3.3 million on one thread.
Is the code open?
Yes, under the MIT license, at github.com/Caliko06/chess-engine-browser.