Play chess against a neural network that runs entirely in your browser. A static demo for Alex Ashworth’s portfolio, built on Chessground with on-device inference.
Play White, Black, or a random side — or just move a white piece to start. Click or drag pieces (dropping the king on its rook castles), promote from an on-board picker, take back a turn, review the game with the move list or arrow keys, export PGN, and resume a saved game. Keyboard users can Tab to a move field that accepts SAN (Nf3, O-O) or coordinates (e2e4). Move and capture sounds are short recordings of wooden pieces and can be muted. The layout fits the viewport without scrolling, from phones to wide desktops. There is no clock or difficulty slider; the model scores every legal move and selects its highest-scoring move without tree search.
Everything runs in the visitor’s browser. The deployment serves static files, including the approved ONNX model. No accounts, server inference, analytics, API keys, Durable Objects, or connection to the Lichess bot service are required. The Lichess link opens that separate bot’s profile.
Use Node.js 24 or newer (.node-version selects 24).
npm ci
npm run devOpen the printed localhost URL (port 5174). For checks and a production preview:
npm run check
npm run previewTo exercise Cloudflare’s actual static headers and routing locally, after building:
npx wrangler dev --local --port 4174npm run build verifies the bundled artifact hashes, prepares the pinned ONNX Runtime files and license notices, and builds dist/. It also rejects files exceeding Cloudflare’s asset limit or a configuration that introduces server execution. No private repository, training environment, GPU, external model download, or Git LFS is needed to build. private: true in package.json prevents accidental npm publication; this Git repository is public.
See deployment instructions for Cloudflare and portfolio embedding, and verification for the tests and their limits.
Chessground board + controls
│ FEN and legal moves in UCI notation
▼
Game controller (chess.js rules)
│ load() / choose(fen, legalMoves)
▼
Dedicated browser Worker
│ selected inference adapter
▼
ONNX Runtime WASM + versioned model artifact
src/config.js: branding, links, artifact identity, and adapter selection.src/game.js: chess rules, turn ownership, saved games, PGN, and stale-reply protection. Independent of Blujay and ONNX.src/main.js,src/style.css: page, board controls, and fixed visual theme.src/engine/client.js,worker.js: asynchronous engine boundary. Heavy inference stays off the interface thread.src/engine/action-value.js,encoding.js: the supplied model’s tensor and token contract. These are the model-specific parts.
The interface uses UCI move notation, not a native UCI subprocess. Another model with this artifact contract can use the same adapter; an arbitrary ONNX model needs an adapter for its inputs, outputs, and encoding. A browser-compatible UCI engine could implement the same load/choose boundary separately. The training repository is not imported, copied, or required.
The included float32 model has 3,713,072 parameters, move-set architecture version 4, and is epoch 10 (averaged weights) of a 12-epoch 4M run on the full corpus trained with mate-distance labels, so faster wins score higher. It also reads each legal move's repetition level (whether the move repeats an earlier position of this game or lets a threefold draw be claimed), which src/repetition.js computes from the game's moves; the repetition input was trained together with the rest of the model, on repetition levels replayed from the training games themselves. The model has a learned square-pair attention bias and a compact board-token embedding; its training data added positions from Blujay-bot's own Lichess games, deeper labels for the worst-labelled positions, tablebase wins ordered by distance to zeroing, and lower labels for repeating moves in won positions where the opponent can steer back into the repetition. In the training repository's evaluation it converted 789 of 989 won positions against Stockfish (the previous model: 760; repetition draws 81 against 131), 632 of 810 on a separate held-out panel (previous: 607), and scored 58.4% over 684 paired-color games against the previous model. Its manifest records the tensor contract, source-checkpoint identity, and file hashes. Model SHA-256:
0afe1e116d5dc965e203f133c429683773e1a19c8cd8a7329417e57a646c306b
The page does not download the model or WASM until a game needs it: Play, a first move on the board, or Continue game after a reload. The first game fetches a 15.28 MB model and a 14.24 MB WASM runtime plus small support files (uncompressed sizes). HTTP caching lets later visits reuse versioned assets, subject to the browser’s cache. There is no offline service worker and no promise that an evicted cache stays available offline.
One WASM thread runs in a dedicated Web Worker; no WebGPU or cross-origin isolation is needed. Scores are evaluated in batches of at most 32 legal moves to bound temporary memory. The session is reused between games. Results are from the side-to-move perspective and are not centipawns or a demonstrated Elo rating. Exact score ties select the first supplied legal move; chess.js ordering can differ from another chess library. A move typically takes tens of milliseconds to choose, so the interface shows each reply no sooner than 450 ms after requesting it; otherwise the engine’s move would land on top of the player’s own. This is presentation only and does not change which move is chosen.
Use HTTPS in production (localhost works for development). A modern browser with WebAssembly SIMD, module Workers, and Web Crypto is required. Device speed and memory affect loading and play. Only Chromium was exercised for this initial release; resized desktop viewports are not physical iOS/Safari testing.
For new weights, add a new versioned model directory, update the path and SHA in src/config.js, and rerun parity checks against that export. Never overwrite an existing immutable asset path with different bytes. When updating ONNX Runtime, also change its versioned runtime path and bundled upstream notices.
The complete playable application is GPL-3.0-or-later; see LICENSE. The deployed page’s Source link points to the revision used to build it, and Credits & licenses opens the dependency notices. Chessground supplies the board mechanics and Cburnett pieces; this app supplies its own controls and colors. The move sounds are CC0 recordings; see the notices. It is not the complete Lichess website.
The bundled ONNX weights, manifest, and encoding data are separately supplied under CC BY 4.0, attributed to Alex Ashworth. These downloadable files are public. The separate training source, datasets, and original checkpoint are not part of this repository. See credits and dependency licenses.