Personal · 2026
Chess Engine & Daily Puzzles
A from-scratch chess engine that powers a 3D game on this site, and the daily puzzle on the home page, where every puzzle is machine-verified before it ships.
50 daily puzzles (mate in 2 on weekdays, mate in 3 on weekends), each proven to have exactly one winning first move.
- Lichess puzzle DB (CC0)
- Filter + replay
- Exhaustive solver check
- Daily puzzle + streaks
The engine
Chess Master runs on an engine I wrote in TypeScript: a flat 64-square board, legal move generation (castling, en passant, promotion), check and mate detection, and a search-based AI with four difficulty levels. The AI runs in a Web Worker, so the 3D board (Three.js) stays smooth while the computer thinks. There's also a multiplayer mode with ratings.
The puzzle problem
I wanted the home page to have something to do, not just read, so it opens with a daily "mate in 2". A puzzle with two correct answers, or one that's secretly a mate in 1, is a broken puzzle, and I didn't want to hand-check dozens of positions.
So the rule is: no puzzle ships unless the engine proves it.
The verifier
The check is short. For a candidate first move, play it, then ask: does every possible Black reply still leave White a mate in one? Run that for every legal first move, and a valid puzzle has exactly one move that passes, and no move that mates immediately.
The same function runs in the browser when you play. That means a correct move is recognised even if it isn't the one in my data, and it costs about 2ms per click.
Where the puzzles come from
Hand-composed positions look artificial, so most puzzles come from real games in the Lichess puzzle database, which is CC0. The file is about 300MB compressed, so instead of downloading it I streamed it and stopped after the first 600 mate-in-2 rows. A script then:
- replays the opponent's last move to reach the puzzle position;
- keeps White-to-move positions with a sensible rating, popularity and piece count;
- runs the verifier and keeps only puzzles with exactly one key move that matches Lichess's solution.
95 positions survived. I picked 33 across the difficulty range, added two of my own, and shuffled them so the difficulty varies day to day.
Weekends get a harder mate in 3, picked the same way: 15 positions, verified by a generalised version of the same solver. A full mate-in-3 search can take over a second on a quiet first move, too slow for a click, so those puzzles store their first move, and the test proves it's the only one that works. Every move after that is still checked live by the solver.
A smoke test re-verifies all 50 puzzles on every run. Past puzzles live in the puzzle archive.
Streaks and sharing
Your streak lives in your browser (no account needed). The share button produces a Wordle-style result, with 🟥 for each miss and 🟩 for the solve.
What I took away
When correctness can be computed, compute it. A 60-line solver replaced an afternoon of manual checking, and it keeps checking every time the puzzle list changes.