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

opened this

Merged 32d 21h ago, 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.

Notes

opened this

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, and swap(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 returns same-cell. Both hand back the same state object. Any move after the game has ended returns over.
  • 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, is Out 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 solution could drive a hint later.
  • No larger grids or difficulty levels.
  • shell.js, index.html, town.js and rounds.mjs are untouched.

Try it: bun test quilt.

Closes #217

commented

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, and swap(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 returns same-cell. Both hand back the same state object. Any move after the game has ended returns over.
  • 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, is Out 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 solution could drive a hint later.
  • No larger grids or difficulty levels.
  • shell.js, index.html, town.js and rounds.mjs are untouched.

Try it: bun test quilt.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs