Notes on the opponent

How FumbleChess works

Your opponent is a neural network that learned chess by imitation. It was shown about a million positions from real games per level and trained to guess which move the human played. On top of that it runs a small Monte-Carlo tree search, deliberately short and always guided by the human-trained network. The goal is not the strongest possible chess. It is play that feels like a person of a given rating, blunders included.

~1M
Lichess positions per level
7M
parameters per network
24–180
positions searched per move
0
servers: it runs in your browser

1. From board to move

The network does not see a picture of the board. It sees 64 tokens, one per square, and each token is a list of 34 numbers. Here is square e4 after 1. e4 e5 2. Nf3:

Token e4 · 34 numbers

a
Pieces, 12 on/off flags. One is on: a white pawn stands here.
b
Turn and castling. Black to move (0), all four castling rights (1 1 1 1).
c
En passant target square. Not this one.
d
Seen before, once or twice: how the network notices repetitions.
e
Clocks. The 50-move clock and the move number, divided by 100.
f
Last 6 moves, a from and a to flag each. The pawn arrived here three plies ago, because people react to what was just played.

Those 64 tokens then go through four stages:

  1. 64 × 34Square encoderA learned layer turns each token into 256 numbers and adds an “I am square e4” embedding.
  2. 64 × 256Local mixerTwo ConvMixer blocks slide a 3×3 filter over the grid. Pawn chains and castled kings are neighbourhood things.
  3. 64 × 256Transformer8 layers of self-attention, 8 heads each. Every square can look at every other, so a bishop sees down its diagonal.
  4. 4,096 · 3Two headsPolicy: a score for every from → to pair, 64 × 64. Value: win, draw and loss.

2. Three opponents, three crowds

Each level is its own network, trained on the Lichess open database (January to April 2024). A game counts only if both players are inside the band, because a 1000-rated and a 2500-rated player differ in which moves they choose, not only in how often they blunder. The policy head learns to put probability on the move the human actually played (illegal moves are masked out); the value head learns the game's final result. 3,500 steps of 512 positions, about 30 minutes per level on a laptop.

Level1Beginner2Club3Master
Lichess rating of both players800–12001600–24002400+
Games × positions per game100k × 10100k × 1040k × 25
Plays the human's move144.9%42.4%43.2%
Positions searched per move2496180
Temperature T1.00.80.6
Rating against Stockfish2840 ± 1961074 ± 1381312 ± 121

1 Top-1 agreement on held-out positions the network never trained on. 2 Fitted from games against limited-strength Stockfish, on Stockfish's own Elo scale, which is not the Lichess scale of the training data. A rough, relative number.

3. Thinking ahead, a little

One glance at the board gives the AI a gut feeling: which moves look natural, and who seems to be winning. The search tests that feeling by playing a few lines out in its head, one simulation at a time.

  1. SelectWalk down the tree, at each step taking the move with the best mix of how good it has looked and how natural the network finds it, plus a bonus for moves tried rarely (PUCT).
  2. ExpandAt a position never seen before, ask the network once: the policy gives each move a prior, the value says who is better. No random playouts.
  3. Back upPass that value up the path, flipping its sign at every ply: good for one player is bad for the other.
  4. ChooseWhen the budget is spent, sample a move by how often each was visited. Not always the top one, so no two games are alike.

Why so little search? With 24 to 180 simulations (and a time cap) the visit counts stay close to the network's human priors. The search only nudges the AI away from moves its own value head dislikes, so it keeps its human habits. And it still fumbles, on purpose:

  • ?!

    It samples. The most-visited move is likely, not certain. Lower levels sample more loosely.

  • ?

    Its judgement is rough. The value head was trained on who won human games, not on deep analysis.

  • ??

    It sees a few moves ahead. A tactic one ply past the horizon is invisible, just like at the club.

4. The bar is a different brain

Plays

FumbleChess network

  • Learned from people
  • Asks “what would a player of this rating play?”
  • About 20 ms per position, a handful of them
  • Outputs a move

Judges

Stockfish

  • Calculates by brute force
  • Asks “what is objectively best?”
  • 300 ms of deep search
  • Outputs centipawns (100 = one pawn), or M3 for a forced mate

The centipawn score becomes an expected result for White, which fills the bar. So the AI plays like a human while the bar judges like an engine. When the two disagree, you have probably just watched a human-style mistake.

Show the maths
Priors
The policy head scores each legal move i with si; a softmax turns them into priors: Pi = exp(si) / Σj exp(sj).
Value
The value head gives win, draw and loss probabilities. For the side to move, v = P(win) − P(loss), between −1 and 1. A move's expected score is (v + 1) / 2.
Selection (PUCT)
At a node with N visits, pick the move maximising Q + c · P · √N / (1 + n): Q its average value so far for the mover, P its prior, n its visits, c = 1.5. Untried moves start at their parent's value minus 0.2.
Final choice
With root visit counts ni, the move is drawn with probability ni1/T / Σj nj1/T. A lower T leans harder on the most-visited move.
Speed
Positions are evaluated 8 at a time, with “virtual loss” so the 8 walks spread out. Each costs about 20 ms in WebAssembly on one thread, hence the small budgets.
Bar fill
E = 1 / (1 + 10−cp / 400), the standard Elo logistic. 0 cp gives 50%, +100 cp about 64%, +400 cp about 91%.
Policy size
64 from-squares × 64 to-squares = 4,096. The head builds a query and a key vector per square and scores each pair by their dot product. Promotions are always to a queen.
Training loss
Policy: cross-entropy between the softmax over legal moves and the human move. Value: cross-entropy between the predicted win/draw/loss and the game result.

5. It all runs in your browser

The networks run with ONNX Runtime Web (WebAssembly) in a worker, and Stockfish runs in another. Nothing is sent to a server. Your game, level, colour and theme stay in your browser's local storage.

Credits

Ideas and research

  1. McIlroy-Young, Sen, Kleinberg, Anderson. Aligning Superhuman AI with Human Behavior: Chess as a Model System. KDD 2020 (Maia). The idea of one model per rating band.
  2. Tang, Jiao, McIlroy-Young et al. Maia-2: A Unified Model for Human-AI Alignment in Chess. NeurIPS 2024.
  3. Ruoss et al. Amortized Planning with Large-Scale Transformers: A Case Study on Chess. NeurIPS 2024. Transformers playing chess without search.
  4. Vaswani et al. Attention Is All You Need. NeurIPS 2017.
  5. Xiong et al. On Layer Normalization in the Transformer Architecture. ICML 2020 (pre-LayerNorm).
  6. Trockman and Kolter. Patches Are All You Need? 2022 (ConvMixer).
  7. Kocsis and Szepesvári. Bandit Based Monte-Carlo Planning. ECML 2006 (UCT, the basis of tree search).
  8. Browne et al. A Survey of Monte Carlo Tree Search Methods. IEEE Transactions on Computational Intelligence and AI in Games, 2012.
  9. Silver et al. A general reinforcement learning algorithm that masters chess, shogi, and Go through self-play. Science 2018 (policy and value heads, and neural-network-guided tree search with PUCT).

Data

Engine

  • Stockfish by the Stockfish developers (GPLv3).
  • Stockfish.js by Nathan Rugg and Chess.com (GPLv3), the WebAssembly build used for the evaluation bar.

Software

  • Chessground, the board, by the Lichess team (GPL-3.0-or-later).
  • chess.js by Jeff Hlywa (BSD-2-Clause), game rules.
  • python-chess by Niklas Fiekas (GPL-3.0), data preparation.
  • PyTorch (Paszke et al., NeurIPS 2019), model and training.
  • ONNX Runtime Web by Microsoft (MIT), running the models in the browser.
  • Vite (MIT) and TypeScript (Apache-2.0).

Pieces

  • Piece set “cburnett” by Colin M.L. Burnett (GPL-2.0-or-later), shipped with Chessground; board colours from its brown theme.

FumbleChess is an educational project. It is not affiliated with Lichess, Chess.com or the Stockfish team.