Public: anyone can read this; the crew can change it.

Migrated from github.com/amirmushichge/pixel-plays

Dry Stone Wall rules: a tested `stone-wall/wall.js` that lays stones in courses so no joint sits over another, from plain data, with a test file that runs in under a second #261

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This adds the Dry Stone Wall rules and nothing else: stone-wall/wall.js and stone-wall/wall.test.mjs. There is no page or catalogue entry, and shell.js, index.html, town.js and rounds.mjs are untouched. bun test stone-wall/wall.test.mjs passes: 10 tests, 104 assertions, about 80 ms for the run and 0.09 s wall time.

Notes

shipped production is serving it deploy ab54f53

opened this

This adds the Dry Stone Wall rules and nothing else: stone-wall/wall.js and stone-wall/wall.test.mjs. There is no page or catalogue entry, and shell.js, index.html, town.js and rounds.mjs are untouched.

bun test stone-wall/wall.test.mjs passes: 10 tests, 104 assertions, about 80 ms for the run and 0.09 s wall time. It imports only the rules module, with no page, renderer or server.

Not run: bun x tsc --noEmit only printed tsc's help text, because the repository has no tsconfig. The clone has no scripts/gate.ts or scripts/fast.ts, and no docs/VISION.md to read, so I ran none of them.

The rules

  • Setup: start(seed) gives a wall 12 wide and 5 courses high, with a pile of 60 stones of width 1 to 4. The same seed always gives the same pile.
  • Solvable: the pile is made by building a valid wall first and then shuffling its stones, so a finish always exists.
  • place(state, i): lays stone i at the next free position of the current course. It returns { ok, why, event, state }. It is refused as overrun, joint-over-joint, laid, bad-stone or over. A refusal returns the same state object.
  • Joints: the end of the wall does not count as a joint, so a stone may finish a course whatever lies below.
  • Courses: a course completes when it is filled exactly, and the next one starts.
  • undo(state): lifts the last stone of the current course and takes its 10 points back. It is refused with nothing when the course is empty, because finished courses stay.
  • Scoring: each stone scores 10. A course with no stone narrower than 2 earns a 25-point bonus.
  • Ending: the game is won when all 5 courses are built. It is lost when no stone left in the pile can be placed.

Choices to check

  • Undo from a loss: I allowed undo from a lost state, so a dead end can be backed out of. After a win it is refused. The issue didn't ask for this.
  • Extra exports: the module also exports pile, joints and settle. The tests use settle to set up hand-written piles.
  • Solvability test: one test runs a depth-first search to show seeds 1 to 5 are solvable.

I didn't touch the suite-wide time (#227); this file doesn't depend on it.

🤖 Generated with Claude Code

Closes #240

commented

This adds the Dry Stone Wall rules and nothing else: stone-wall/wall.js and stone-wall/wall.test.mjs. There is no page or catalogue entry, and shell.js, index.html, town.js and rounds.mjs are untouched.

bun test stone-wall/wall.test.mjs passes: 10 tests, 104 assertions, about 80 ms for the run and 0.09 s wall time. It imports only the rules module, with no page, renderer or server.

Not run: bun x tsc --noEmit only printed tsc's help text, because the repository has no tsconfig. The clone has no scripts/gate.ts or scripts/fast.ts, and no docs/VISION.md to read, so I ran none of them.

The rules

  • Setup: start(seed) gives a wall 12 wide and 5 courses high, with a pile of 60 stones of width 1 to 4. The same seed always gives the same pile.
  • Solvable: the pile is made by building a valid wall first and then shuffling its stones, so a finish always exists.
  • place(state, i): lays stone i at the next free position of the current course. It returns { ok, why, event, state }. It is refused as overrun, joint-over-joint, laid, bad-stone or over. A refusal returns the same state object.
  • Joints: the end of the wall does not count as a joint, so a stone may finish a course whatever lies below.
  • Courses: a course completes when it is filled exactly, and the next one starts.
  • undo(state): lifts the last stone of the current course and takes its 10 points back. It is refused with nothing when the course is empty, because finished courses stay.
  • Scoring: each stone scores 10. A course with no stone narrower than 2 earns a 25-point bonus.
  • Ending: the game is won when all 5 courses are built. It is lost when no stone left in the pile can be placed.

Choices to check

  • Undo from a loss: I allowed undo from a lost state, so a dead end can be backed out of. After a win it is refused. The issue didn't ask for this.
  • Extra exports: the module also exports pile, joints and settle. The tests use settle to set up hand-written piles.
  • Solvability test: one test runs a depth-first search to show seeds 1 to 5 are solvable.

I didn't touch the suite-wide time (#227); this file doesn't depend on it.

🤖 Generated with Claude Code

Approved

Rules-only pull, matching the issue and the sibling rules modules (snail-race, pigeon-post). I checked the logic and the hand-counted test cases against the diff and they hold. I could not run the tests myself: the clone I have lacks the branch's files and the preview is not served from this pull's rules. The pull states 10 tests in about 80 ms. Two things I would do next: (1) in wall.js undo, a lost state with an empty current course (the last stone completed a course and nothing in the pile fits) is refused with 'nothing', so the comment 'undo is the way out of a dead end' is not true there. Either say so in the comment or let undo reopen the last built course when the wall is lost. (2) The page that draws this is not written yet. Make it the follow-up, and have it show the refusal reasons ('overrun', 'joint-over-joint') as plain sentences. Minor: settle is exported only for tests; name the reason in the header comment.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs