Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Patchwork Quilt rules: a tested `quilt/patch.js` where you rotate and swap square patches until every stitched edge matches its neighbour, from plain data #232
Check · Review · Land · Live done — Landed and live in production.
This adds the Patchwork Quilt rules as quilt/patch.js and quilt/patch.test.mjs, with no page and no catalogue entry. bun test quilt passes (10 tests) and bun x tsc --noEmit is clean. There is no scripts/gate.ts or scripts/fast.ts in this clone, so I ran neither, and I did not run the full suite.
shipped production is serving it deploy ab54f53
This adds the Patchwork Quilt rules as quilt/patch.js and quilt/patch.test.mjs, with no page and no catalogue entry. bun test quilt passes (10 tests) and bun x tsc --noEmit is clean. There is no scripts/gate.ts or scripts/fast.ts in this clone, so I ran neither, and I did not run the full suite.
Rules
- Start:
start(seed)gives a 3×3 quilt, 4 stitch patterns, a 24-move limit and 12 shared edges. The quilt is sewn so every shared edge matches, then scrambled from the seed. It is never left already finished. - Solvable: the scramble is 5 swaps and 5 quarter turns in a seeded order. Undoing it takes at most 20 moves (a swap undoes in one, a quarter turn in three), so 24 always suffices.
solution(seed)returns those undo moves, and the test replays it for 100 seeds. - Moves: a cell is its index 0–8, counted along rows.
rotate(state, cell)turns the patch a quarter turn clockwise, andswap(state, a, b)exchanges two patches. Each counts as one move. - Refusals: a cell off the grid returns
bad-cell, and swapping a patch with itself returnssame-cell. Both hand back the same state object. Any move after the game has ended returnsover. - Matching:
matches(state)lists every shared edge as{a, b, ok}. An edge matches when the two touching stitches are equal. - Scoring: a move that raises the matching count scores 10. Finishing scores 5 for each move left, so a win on move 20 earns 20 on top of the 10 from the move that finished it. The win line is
Quilt finished: N points, M moves to spare. The loss line, once the limit is reached first, isOut of moves: X of 12 edges match, N points. A win on the last allowed move counts as a win.
Not done
- No hint button or UI, though
solutioncould drive a hint later. - No larger grids or difficulty levels.
shell.js,index.html,town.jsandrounds.mjsare untouched.
Try it: bun test quilt.
Rules-only pull, like the other rules pulls (rain-barrel, etc.): plain data in and out, no DOM, seeded, no dependency. The scramble is built from 5 swaps and 5 turns, so undoing it takes at most 20 moves, inside the 24-move limit. The test replays the solution for 100 seeds. Refused moves return the same state object. Not run here: I could not fetch the branch into my sandbox, so I did not run the tests myself. I relied on the pull being green and on reading the diff. The preview answers 200 and has no quilt page yet, which is expected for this scope.
Two things to do next:
- Add the playable page and catalogue entry for the quilt. Make it usable by keyboard and on a 360px phone: each patch needs a focusable button with an accessible name, because rotate and swap must not depend on a pointer. Show the win and loss line in an aria-live region.
- Give the tty door the same moves, and credit the original puzzle family (edge-matching tile puzzles such as Eternity) on the page.
Small note: the gain-score test only asserts that some rotation scores at least GAIN_SCORE. Assert the exact score for one known gain.
This adds the Patchwork Quilt rules as
quilt/patch.jsandquilt/patch.test.mjs, with no page and no catalogue entry.bun test quiltpasses (10 tests) andbun x tsc --noEmitis clean. There is noscripts/gate.tsorscripts/fast.tsin this clone, so I ran neither, and I did not run the full suite.Rules
start(seed)gives a 3×3 quilt, 4 stitch patterns, a 24-move limit and 12 shared edges. The quilt is sewn so every shared edge matches, then scrambled from the seed. It is never left already finished.solution(seed)returns those undo moves, and the test replays it for 100 seeds.rotate(state, cell)turns the patch a quarter turn clockwise, andswap(state, a, b)exchanges two patches. Each counts as one move.bad-cell, and swapping a patch with itself returnssame-cell. Both hand back the same state object. Any move after the game has ended returnsover.matches(state)lists every shared edge as{a, b, ok}. An edge matches when the two touching stitches are equal.Quilt finished: N points, M moves to spare. The loss line, once the limit is reached first, isOut of moves: X of 12 edges match, N points. A win on the last allowed move counts as a win.Not done
solutioncould drive a hint later.shell.js,index.html,town.jsandrounds.mjsare untouched.Try it:
bun test quilt.Closes #217