A chess bot that plays like me

An opening book and habits from my own chess.com games, Stockfish reweighted to match them, a held-out eval against a plain engine, and its limits.

8 min read

I play and teach chess, and as of 2026-11-09 my chess.com archives hold 13,909 games, going back to April 2021. The Off the clock level on this site turns those games into an opponent: Play Daniel. It opens the way I open, then picks engine moves the way I tend to pick them, turned down to play nearer my rating.

I didn't write it by hand. The site was built by a team of Claude Code agents that I directed. An AI-engineer agent wrote the data pipeline, the bot and the evals, and a QA agent re-ran them. This post covers how the bot works and what the numbers say, including the part where "plays like me" turns out to mean mostly "opens like me".

The data

Only rapid and daily games

As of 2026-11-09 the archives have 8,888 rapid games, 4,241 blitz, 449 daily and 331 bullet. My rapid rating is 1,286, and my best was 1,506. The bot learns only from rapid and daily, which is the pool the spec set.

The agent also tested adding blitz to the opening book. On the held-out games, the bot's top-1 match came out at 42.8% with blitz against 43.0% without. No better, so blitz stayed out.

A split by date, not at random

The eval needs games the bot has never seen. The script holds out the most recent 10% of my rapid and daily games by end time: 934 games (919 rapid, 15 daily), played from 2026-07-16 to 2026-11-09. The other 8,403 games train the book and the habits.

A random split would leak. A test game from last week would sit next to training games from the same week, with the same openings I happened to be playing then. A date split asks the honest question: from what I played before, can it predict what I played next?

The cutoff is a timestamp, not a list of games. Games of any time class that end after it never reach the book or the fit, so a blitz game from the test period can't sneak in through a side door either.

How the bot picks a move

The bot works in three layers, in order:

1. Book      position I reached at least twice → one of my moves there, weighted by count
2. Engine    Stockfish's top 8 candidates → scored by my habits → one is sampled
3. Fallback  no engine → a one-ply heuristic that never allows mate in one

The opening book

For each colour, the build walks my training games through the first 40 half-moves and records the move I played in every position where it was my turn. Positions I reached only once are dropped. The keys are a normalised FEN (without the move counters) hashed into a short string, so a transposition lands on the same entry. The shipped book has 2,160 positions as White and 2,258 as Black.

In a book position the bot samples one of my moves in proportion to how often I played it. If I played a move three times out of four, it plays it about three times out of four.

Engine candidates, reweighted by habits

Out of the book, Stockfish 19 runs in MultiPV mode and returns its 8 best candidates, using a budget of 60,000 nodes per move. The budget counts nodes rather than milliseconds, so the same seed and move list give the same candidates on any machine.

Each candidate gets 17 features. Two come from the engine: how many pawns it loses against the best candidate, and its rank. The rest describe what kind of move it is: a capture, a check, castling, which piece moves, a king walk, a recapture, a retreat, a flank pawn push, and so on. A conditional logit (a softmax over the candidates) learns one weight per feature, separately for the opening, middlegame and endgame. It's fitted on my most recent 300 training games: 6,781 positions.

The weights read like a description of my play. In the opening, castling gets +1.08 and a king move that isn't castling gets −1.38. In the endgame, captures get +1.73 and checks +1.24. I like grabbing things.

One limit is built in. My move was among the engine's candidates in only 84.1% of the fit positions. In the rest, the habits have nothing to choose from.

The baseline in the eval uses the same candidates and the same fit, but only the "pawns lost" weight is free. That gives the same engine at a similar strength, with no book and no habits.

A temperature to bring it down to my level

The fitted bot was too strong. At temperature 1 it scored 90% against Stockfish at its weakest setting (UCI_Elo 1320) over 36 games, far above my level. The agent then raised the sampling temperature, which flattens the probabilities so worse candidates get picked more often:

  • 1.5: 71% (36 games)
  • 1.75: 55% (54 games)
  • 2: 36% (36 games)

1.75 shipped, because it lands near an even score. These are small samples, and they're recorded in a comment in scripts/chess/lib/config.ts, not in a committed results file. Treat them as a rough calibration. The hint button and the eval use the bot's single most likely move, which the temperature doesn't change.

Does it play like me?

The numbers

The eval replays the held-out games and asks, for each of my non-forced moves: is the bot's single most likely move the move I played? The baseline gets the same question. As of 2026-11-09, over 30,461 moves from all 934 held-out games:

Moves Positions Bot v1 Baseline Difference
All 30,461 43.0% 37.8% +5.2 pp
Opening (ply ≤ 20) 9,262 51.0% 38.4% +12.6 pp
After the opening (ply > 20) 21,199 39.5% 37.5% +2.0 pp

Most of it is the opening

The headline gain of +5.2 pp is mostly the book. In the opening, 46.2% of the positions are answered from the book, and the gap to the baseline is +12.6 pp. After the first 20 half-moves the book almost never answers (its share there rounds to 0), and the habits add +2.0 pp over a plain engine. The book does go on to half-move 40, but it keeps only positions I reached at least twice, and that deep into a game my positions rarely repeat, so the few late entries it has almost never come up in a new game. Over all moves, 14.0% came from the book.

So, as of 2026-11-09, the honest summary is: it opens like me, and after that it's a slightly personalised Stockfish.

The eval also reports how much probability the sampling policy puts on my actual move, at temperature 1: 33.0% for the bot, 22.2% for the baseline, and 24.7% for Stockfish's own weakest setting played once per position. The shipped bot samples at 1.75, though, and that setting isn't measured here. The table measures the bot's top choice, not every move it plays.

A gate for the weekly refresh

A weekly job downloads new games, rebuilds the book and habits, re-runs the eval, and opens a pull request only if the bot's match rate hasn't dropped by more than 1 pp. Nothing deploys until I merge it. It has run on GitHub now. The first run, with nothing cached, was cancelled at its 90-minute limit. The second passed the gate and the legality run, and I merged its pull request.

Every move the bot returns is checked against chess.js's legal moves before it's played. The test is blunt. As of 2026-11-09 the bot played 500 games against a seeded random mover: 10,527 bot moves (750 from the book, 9,777 from the engine) and 0 illegal. It won all 500, which says nothing about strength. A random mover is the one opponent I'm confident I'd beat too.

A second run forced the engine to fail, so the fallback picker played every off-book move: 100 games, 2,480 bot moves, 0 illegal, with 97 wins, 2 draws and 1 game stopped by the move cap. The QA agent re-ran both during the launch review and got the same result.

Running it in the browser

A worker, and a plan for when it fails

Nothing chess-related loads until the visitor presses Play. QA counted 0 chess requests before that. The bot runs in a Web Worker, and Stockfish (the stockfish.js lite build, compiled to WebAssembly) runs in a second worker nested inside it, so the page stays responsive while it thinks.

If the worker sends nothing within 1.5 s, the page treats it as dead and answers on the main thread instead: book first, then the heuristic, with a small notice. Each move has a 2,500 ms deadline in the worker. The requirement is that a move or a clear message appears within 5 seconds, even when things break. QA tested this in Chromium at 4x CPU throttling:

  • silent worker: a move after 1,845 ms, with the notice
  • engine file returns 404: 19 ms, with the notice
  • engine script hangs: 15 ms (a book move)
  • everything normal: 30 ms

Slow networks: book moves now, the engine later

The engine binary is about 1.2 MB gzipped. The two book files are 26,656 B and 27,628 B. On a slow connection, the bot shouldn't sit and wait for the big file, so the worker reports ready as soon as the books and habits have loaded. Stockfish keeps downloading in the background.

Book moves are answered at once. An off-book move waits for the engine for a bounded time:

const wait = Math.min(ENGINE_WAIT_MS, deadline - performance.now());
const sf = await Promise.race([pending, sleep(Math.max(0, wait)).then(() => null)]);
if (!sf || sf.dead) throw new Error("engine not ready"); // decide() falls back

The wait is at most 800 ms. After that, the fallback picks that one move. A slow download counts as "loading", not as a failure. Only 10 seconds with no bytes arriving counts as stalled. When the engine finishes loading, the game upgrades to Stockfish from the next move on.

The bot worker downloads the binary itself and hands the bytes to the nested engine worker. That gives three things: the file is fetched once even with the HTTP cache off, no blob: URL is needed (the CSP only allows workers from the site itself), and a missing or broken file is caught before it reaches Stockfish's loader.

What's still unproven

  • A real phone. QA emulated a phone at 4x CPU throttling: 115 bot moves, p50 77 ms, p95 90 ms, max 160 ms. That machine had all its cores busy with unrelated processes, so the numbers are pessimistic, but it still isn't a real mid-range phone. Nobody has run that test yet.
  • Safari. The nested engine worker hasn't been tested in Safari or on iOS. WebKit wasn't available for the QA run.
  • Strength. The temperature comes from 36 to 54 games per setting. "Nearer my rating" is a rough fit.
  • The middlegame. After the opening, the habits add 2.0 pp. That's real, but small.

The next step is a model trained on my own games instead of a reweighted engine: a Maia-style network, planned for a later milestone. It only replaces this bot if it beats it by at least 3 pp on the same held-out games, and it has to stay at 10 MB gzipped or less. Until then, if the bot opens like me and then plays better than me, that's on Stockfish.