The games
They come from ElephantChess, which publishes its own site’s games as anonymised monthly dumps under GPL-3.0. Amateur games, which matters: strong players do not blunder often enough to be a supply.
A run freezes its game list before any engine time is spent, sampled across ratings, time controls, results and lengths so it is not all blitz. Nothing is added to a run once it starts.
Every source carries a licence status, and publishing refuses any puzzle whose source has not been cleared.
The algorithm
Two passes: a cheap one over every position of every game, and an expensive one over the few that survive it.
The cheap pass replays a game and stops at every position after ply 8, asking Pikafish for its top two moves at 60,000 nodes, roughly depth 10 to 14. It is shallow on purpose, because it runs everywhere.
A position becomes a candidate when the move played loses at least 250 centipawns against the engine’s best and leaves the other side winning by at least 250. A blunder that leaves the game equal has nothing to find.
A centipawn is a hundredth of a soldier, the unit engines use for material. Xiangqi has no pawn, so the name comes from chess along with the scale. This site puts a horse or a cannon at 450 and a chariot at 900, so 250 centipawns is about half a horse.
Two filters narrow it. Positions already decided by 800 centipawns are skipped, because winning a won game harder is not a tactic. No game gives up more than three candidates, so one collapse cannot flood the corpus with variations on itself.
The expensive pass sends each candidate back to the engine at depth 20 and 600,000 nodes, ten times the budget, as a bare FEN with no move history, so the engine cannot lean on the search it just did.
Then the line is built one solver move at a time, and every move has to be uniquely best on its own. A principal variation is one line the engine liked from one search. It says nothing about whether move three was forced, and a solver who finds a different move three and is told they are wrong has been lied to.
Uniqueness is not a centipawn gap. Two moves 50 centipawns apart are both fine, and demanding one punishes a solver for choosing correctly. A move is the answer when every alternative gives the win away. A second move that still wins, even by a whole piece less, is a second answer. The test is a hand-tuned cascade, and it fails closed: anything it cannot separate is thrown away.
What survives goes to an audit. A separate process, knowing nothing of what the first pass decided, searches every solution again at depth 22 with no node ceiling and drops the roughly 6% that do not hold up.
The code
The cheap pass, condensed. One detail halves the searches: judging a move needs the position’s value before and after, and if the scans stay in order both are already there, because the move played is worth the negation of the next position’s score.
// packages/game/src/puzzles-xiangqi-mining.ts (condensed)
// scans[i] is the engine's best score at the position BEFORE move i, from the
// point of view of whoever is to move there. That one array is enough to
// judge every move in the game: the value of the move played from
// position i is -scans[i + 1], because position i + 1 is the same position
// scored by the opponent. One search per position, not two.
for (let ply = minPly; ply < moveCount; ply += 1) {
const pre = scans[ply]; // the best that was available
const post = scans[ply + 1]; // what they left behind, opponent's view
if (pre === null || post === null) continue;
if (Math.abs(pre) >= decidedCp) continue; // already decided: no tactic
if (post < winCp) continue; // solver must end up winning
const playedCp = -post; // the move, in their own terms
const swing = pre - playedCp;
if (swing < swingCp) continue; // a mistake, but a small one
candidates.push({ ply, swingCp: swing, preBestCp: pre, postBestCp: post });
}In August 2026 mining cost about six core-hours per thousand games, or about one core-minute per published puzzle.
And the gate. Every branch that returns false is a way a real blunder fails to be a puzzle.
// packages/game/src/puzzles-xiangqi-mining.ts (condensed)
const winRate = (cp) => 1 / (1 + 10 ** (-cp / 400));
// Is this solver move THE answer, or merely a good one? Every branch that
// returns unique:false is a reason a real blunder failed to become a puzzle.
function classifySolverMove(best, second) {
if (!best) return { unique: false, reason: 'missing-best' };
// Mate saturates both centipawns and win%, so mates get their own rule:
// unique only when no other move mates at all, however slowly. A mate in
// one is the exception: the trainer accepts any move that mates on the spot.
if (mates(best)) {
if (best.mate === 1) return { unique: true, reason: 'mate-in-one' };
if (!second || !mates(second))
return { unique: true, reason: 'only-mate' };
return { unique: false, reason: 'mate-not-unique' };
}
if (winRate(best.scoreCp) < 0.8)
return { unique: false, reason: 'best-not-winning' };
if (!second) return { unique: true, reason: 'only-move' };
if (mates(second)) return { unique: false, reason: 'runner-up-mates' };
const gapCp = best.scoreCp - second.scoreCp;
if (gapCp < 200) return { unique: false, reason: 'near-tie' };
// The runner-up is wrong only if it gives the win away. One that still
// wins is a second answer, however much less it wins by.
if (winRate(second.scoreCp) <= 0.6)
return { unique: true, reason: 'runner-up-loses-win' };
return { unique: false, reason: 'alternative-still-good' };
}What it keeps
Two thirds of the puzzles open with a move that captures nothing. If you hunt for tactics by scanning the captures first, as most of us do, you start in the wrong place two times in three.
Only about a tenth involve giving material away. Sacrifices are the tactics people remember, so I had expected more. In real games the winning move is usually just a move. In this one the solver is already a horse and a cannon down, and gives more away.
Not every puzzle ends in mate. About 40% end with the solver simply winning, and a mate-shaped intuition misses those. This one opens with a quiet move, hands a soldier back, and collects an advisor and both horses for it.
And one that takes nothing for four plies. Red starts 150 centipawns down, and the engine calls the position level.
What it throws out
The rejects define a puzzle better than the keeps do, because each one is a real blunder that failed for exactly one reason.
| Outcome | Share of candidates |
|---|---|
| Rejected: near-tie | 36% |
| Rejected: too short | 25% |
| Rejected: promised mate not reached | 8% |
| Rejected: not unique, or not winning | 26% |
| Survived to the audit | 6% |
Near-tie is the biggest, about a third. The position had two winning moves, so there is no single answer to check against, even though the blunder was real.
Too short is another quarter, and it gives the clearest example of what the miner is for. In this rejected position Black is to move, the engine scores a forced mate against a second-best line of +1407, and exactly one of Black’s twenty legal moves does it.
The other way to fail is too many answers. Below, Red is to move and the horse on e8 mates two ways, c9 or g9, and the board plays one of them. Either wins, so there is nothing to check a solver against.
Promised mate not reached is the narrow one, and it is not a rule against non-mate puzzles. It fires only when the engine returned a mate score and replaying the line inside the seven-ply cap never reached the mate. A position with an ordinary winning evaluation never enters that branch, and ships as a winning-advantage puzzle like the ones above.
A rating scores what makes the line hard to see
Every puzzle needs a rating before anyone has solved it, so the trainer can pick problems near your level. Rating by mate depth gives four distinct values across the corpus. The rating walks the solution instead: a quiet first move adds, a capture subtracts, a sacrifice the solver never wins back adds up to 200, and the number of replies the defender has pushes it either way. On 2 September 2026 the 1,415 puzzles served had 479 distinct ratings between 1000 and 2600.
The largest penalty goes to a first move that takes a piece nothing can take back, scaled by that piece and capped at a chariot’s 900, because a hanging piece is the easiest thing on a board to spot. The check runs only while the game is still going: a capture that mates also leaves no legal reply, and counted naively it would look like a free piece and mark down every mating capture in the corpus.
One kind of position is withheld: the solver is already at least 300 centipawns ahead and the answer takes something undefended. It teaches nothing at any rating, and a rating can only decide who gets shown a problem. That rule hid 12% of the corpus.
What a puzzle turns out to be
Most winning positions have several winning moves, and a third of everything found died on that alone. A puzzle is a position with one answer, deep enough that finding it takes work, and stable enough that a stronger engine still agrees an hour later. Nineteen mistakes in twenty do not qualify.
One caveat: the gate has never been checked against human solvers. Its three thresholds came from reading rejected positions; nobody has measured whether the puzzles they admit are any good, and the win-rate curve they act on comes from chess. Solve and reveal rates are recorded per puzzle, so the data to grade it exists.