263 moves played · 0 takebacks · 0 prisoners
Go on a 9×9 board with area scoring. Rewind past a capture and the captured stones come back.
What fold does here
Each play is stored with the stones it captured, as changes to the board, and a list of plays in force decides the position. The board, the stones and prisoners per colour, and every position the game has passed through are fold views.
Two rules are fold's: one stone per point, and no position may repeat (superko). The second is a rule over a computed view, so a play that would recreate an earlier position is refused before it lands.
Why it shows off fold
Superko is a rule that's awkward almost anywhere else: you'd load the game's history, recompute its positions and check by hand, inside a lock. Here it's declared once (positions are unique) and fold enforces it on every write, all or nothing. And because captures are stored as changes, undoing a capture is plain subtraction: the stones reappear without anyone writing code to restore them.
Worth trying
- Capture a group, then scrub back past it: the stones return and the prisoner count drops.
- Try to retake a ko at once: fold refuses it, and Inspect names the rule.
- Pass twice to end the game and see the score.
Still app code
Groups and liberties, which decide captures and suicide. They need connectivity (which stones touch which), and fold has no recursion to follow a chain of stones, so the app works them out and hands fold the result.
Press \ in the app to watch fold's commits as they happen.