Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Bunting rules: a tested `bunting/line.js` that hangs flags on a string so no two neighbours match, from plain data #197
Check · Review · Land · Live done — Landed and live in production.
This adds the Bunting rules in bunting/line.js, with tests in bunting/line.test.mjs. There is no page and no catalogue entry yet, and shell.js, index.html, town.js and rounds.mjs are untouched. The 8 new tests pass; I ran only those, not the whole suite, and tsc printed its help text because the repo has no tsconfig.
shipped production is serving it deploy ab54f53
This adds the Bunting rules in bunting/line.js, with tests in bunting/line.test.mjs. There is no page and no catalogue entry yet, and shell.js, index.html, town.js and rounds.mjs are untouched. The 8 new tests pass; I ran only those, not the whole suite, and tsc printed its help text because the repo has no tsconfig. The repo has no scripts/gate.ts or scripts/fast.ts, so I ran neither.
- Layout:
start(seed, level)tieslevel + 1strings oflevel + 3hooks, up to level 5. Hooks on neighbouring strings cross at random. Level 1 has 3 patterns and level 4 and up have 4. The same seed and level always give the same layout. - Finishable: each layout is built from a finished hanging (greedy colouring), then flags are taken down. The ones left up are the fixed flags, and the finished hanging is kept as
solution. The tests finish all 60 seeds at every level. - Moves:
- hang costs one move. It refuses a fixed hook, an unknown hook, an unknown pattern, an occupied hook, and any move once the game is over, and says why.
- take removes a flag that isn't fixed and costs no move.
- clashes lists every neighbouring pair that shares a pattern.
- Levels and end: a level clears when every hook has a flag and there are no clashes, and the next, larger level starts. After level 5 the game ends. It wins if the total moves are at most
WIN_MOVES(160), and otherwise reports the loss line with levels cleared and moves.
Choices beyond the issue:
- Occupied hooks: hanging on an already-flagged hook is refused with
occupied, so a flag has to be taken down first. giveUp(state): I added it so a game can end on the loss line before level 5.
To try it: run bun test bunting.
🤖 Generated with Claude Code
Rules-only pull in the same shape as sandcastle/tide.js: pure, seeded, refused moves return the same state with a reason, and the tests build every level from its stored solution across 60 seeds. No page, server or input surface is touched, so there is nothing for a phone, keyboard or JS-off reader to hit yet. Two things I would do next: (1) in bunting/line.test.mjs the clash case in the full-string test sits behind if (bad !== undefined), so it can pass without checking anything; pick a seed where a clash is certain and assert it. (2) The playable page needs a keyboard and screen-reader path for choosing a hook and pattern, with a text rendering of state.line and the clash list, and hooks big enough for a thumb on a 360px screen.
This adds the Bunting rules in
bunting/line.js, with tests inbunting/line.test.mjs. There is no page and no catalogue entry yet, andshell.js,index.html,town.jsandrounds.mjsare untouched. The 8 new tests pass; I ran only those, not the whole suite, andtscprinted its help text because the repo has no tsconfig. The repo has noscripts/gate.tsorscripts/fast.ts, so I ran neither.start(seed, level)tieslevel + 1strings oflevel + 3hooks, up to level 5. Hooks on neighbouring strings cross at random. Level 1 has 3 patterns and level 4 and up have 4. The same seed and level always give the same layout.solution. The tests finish all 60 seeds at every level.-
hangcosts one move. It refuses a fixed hook, an unknown hook, an unknown pattern, an occupied hook, and any move once the game is over, and says why. -takeremoves a flag that isn't fixed and costs no move. -clasheslists every neighbouring pair that shares a pattern.WIN_MOVES(160), and otherwise reports the loss line with levels cleared and moves.Choices beyond the issue:
occupied, so a flag has to be taken down first.giveUp(state): I added it so a game can end on the loss line before level 5.To try it: run
bun test bunting.🤖 Generated with Claude Code
Closes #189