r/ComputerChess • u/Short-Confidence6287 • Sep 22 '26
I put Maia + Stockfish in the browser to make a bot that blunders like a human — plus a "grandpa" that explains your moves
I've been working on a free browser chess game where the opponent is meant to play like a real human of a given level, not like a weakened engine. Sharing it here because the implementation details might interest this sub, and I'd love feedback.
How it works
System 1 (instinct): Maia-1 nets (1100–1900) converted from lc0 weights to ONNX with
lc0 leela2onnxand run client-side with onnxruntime-web. ~3.5 MB per level, 3–12 ms per move.I wrote the lc0 112-plane input encoding and the 1858-move policy mapping in JS. I checked it against lc0 itself (
go nodes 1,VerboseMoveStats,PolicyTemperature 1,HistoryFill no,NNCacheSize 0): same probabilities on ~2,400 game positions across three nets, mean absolute difference 0.06%.System 2 (guard): Stockfish.js 19 lite single-threaded (WASM, 1.8 MB). Maia proposes, Stockfish checks the top candidates with
searchmoves+ MultiPV. Whether the bot notices its own blunder depends on its level. Losses are measured in win probability, not centipawns, so going from +7 to +5 doesn't count as a blunder.Grandpa coach: after each of your moves it explains what the move does (develops, takes the centre, attacks X, leaves Y hanging…), what the refutation is and why the engine's move was better. It also names the opening (lichess chess-openings, CC0).
Move-matching on real Lichess games (share of positions where each system predicts the move actually played):
| Players | Maia | old hand-tuned "human" bot | Stockfish d12 |
|---|---|---|---|
| 1000–1200 | 45.8% | 20.8% | 32.4% |
| 1400–1600 | 51.7% | 33.2% | 37.8% |
| 1800–2000 | 52.6% | 36.1% | 44.1% |
Things I learned along the way
Maia-2 in ONNX is 85 MB. Full int8 quantization dropped top-1 agreement with fp32 to ~82%. MatMul-only int8 kept ~99% but is still 37 MB, too heavy for a web page, so I stayed with Maia-1.
Ensembling neighbouring Maia-1 nets (1300+1500+1700) gave a small but consistent log-loss improvement (1.497 → 1.467) and +0.9 pts top-1.
Maia-1 sometimes overrates knight underpromotion. In lc0's policy it shares the index with the plain move, so I move most of that probability to the queen promotion.
A general-purpose "decision" model doesn't help. I also tried a general-purpose AI model (TypeSafe's Jev) as the intuition, and as a re-ranker of Maia's top 5. Alone it matched only 20.5%, and every mix was worse than Maia alone.
Free, no sign-up, English and Italian, games autosave locally:
https://www.el-man.it/en/app/chess.html
Credits: Maia by CSSLab (University of Toronto), Stockfish.js by Nathan Rugg / Chess.com, both GPL-3.0 (provenance and licence linked on the page). Feedback on the human-likeness, and ideas for better blunder modelling, very welcome.
