Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Lily Pond rules: a tested `lily-pond/pond.js` where a frog must hop every lily pad once before they sink, from plain data #173
Check · Review · Land · Live done — Landed and live in production.
This adds the Lily Pond rules in lily-pond/pond.js, with tests in lily-pond/pond.test.mjs. It has no page and no catalogue entry, and nothing outside the folder is touched. bun test lily-pond passes (8 tests).
shipped production is serving it deploy ab54f53
The rules match the issue and I found no security problem: the module has no I/O, hop validates the direction with Object.hasOwn, and there is no eval or shell. One thing must change before it lands.
Fix first: the snake fallback in lily-pond/pond.js builds an invalid pond. See the line comment.
Two smaller points, neither blocking:
- No test reaches the fallback path, which is why the bug is unnoticed.
target,verdictandDIRSare exported but no test or caller uses them. Keep them only if the later page needs them, otherwise drop them.
I fixed the invalid fallback in lily-pond/pond.js and pushed it to the same branch. bun test lily-pond passes (9 tests). I didn't run tsc or any gate or fast scripts again.
- The fix:
snakenow runs back and forth along the rows. Rowrisfloor(i / SIZE), andxruns left to right on even rows and right to left on odd rows. Every hop is one cell and the pads are distinct, including on levels 4 to 6. - The test: a new test calls
snakefor every level. It checks the pads are distinct and one cell apart, then follows the route withhopto theclearedoroverevent. - Exports: I dropped
DIRS,targetandverdictfrom the module's exports, since nothing uses them yet.snakeis exported so the test can reach it. The page can havetargetback if it needs it.
The generator itself never falls back to snake in practice, so the new test is what covers that path.
🤖 Generated with Claude Code
Rules-only, same shape as the sibling rules pulls (sandcastle, hedge-maze). The module has no I/O, hop validates direction with Object.hasOwn, rejected hops return the same state, and the tests cover generation, solvability across 60 seeds x 6 levels, refusal, sinking, retry, win/loss lines and the snake fallback. Snake is now valid. No dependency, no page to break. Next two things: (1) the page and catalogue entry, with keyboard/arrow-key hops and a 44px-tap D-pad for a 360px phone, plus the same hop in src/tty.ts so both doors work and the README says how; (2) drop the leftover typeof r.state.undo assertion in pond.test.mjs (there is no undo) and credit the original lily-pad hopping puzzle it is modelled on in the page copy when it lands. The extra 7th-retry cap is disclosed and reasonable.
This adds the Lily Pond rules in
lily-pond/pond.js, with tests inlily-pond/pond.test.mjs. It has no page and no catalogue entry, and nothing outside the folder is touched.bun test lily-pondpasses (8 tests).bun x tsc --noEmitprinted only its help text, so it checked nothing, and I didn't run a gate or fast script.How the rules work
start(seed, level)makes a 6×6 pond. Level n has n+3 pads, up to level 6. The same seed and level always give the same pond.hop(state, dir)jumps north, east, south or west to the nearest pad within reach 3, and the pad left behind sinks. A hop with no pad in reach, a bad direction or a hop after the game is over returns the same state with a reason. A successful hop returns an event: none,cleared,lostorover.What I chose not to do
To try it, run
bun test lily-pond/pond.test.mjs.🤖 Generated with Claude Code
Closes #166