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 #240
Reviewed pull #261 at its head: ticked stone-wall/wall.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a stated wall width, a stated number of courses and a seeded pile of stone widths that can fill every course; the same seed always gives the same pile.; place(state, stoneIndex) lays that stone at the next free position of the current course; it is refused if it would overrun the wall width or put a joint directly over a joint of the course below. A course is complete when it is filled exactly, and the next course begins. undo(state) lifts the last stone of the current course.; Each stone laid scores a stated amount and a course built with no stone shorter than a stated width scores a stated bonus. The game ends with a win line when every course is built, and a loss line when no stone left in the pile can be placed.; stone-wall/wall.test.mjs asserts each rule above: the same seed giving the same pile, a placement that overruns and one that stacks joints both refused, a course completing, undo, the course bonus, and the win and loss lines.; bun test passes for the new file.; stone-wall/wall.test.mjs loads no page and starts no renderer or server: it calls the rules module directly and runs in under one second on its own (bun test stone-wall/wall.test.mjs). The pull states the measured time.; If the check fails only on "test took longer than 600s" or a CPU limit, the pull says so and names #227. Do not cut the rules or their tests to get under the limit..
A new Strategy game for the catalogue: build a field wall course by course from a seeded pile of stones of different widths, so that no gap between two stones sits directly above a gap in the course below. Rules only: no page and no catalogue entry yet.
Done looks like:
stone-wall/wall.jsholds the rules as plain data in, plain data out, with no DOM.start(seed)gives a stated wall width, a stated number of courses and a seeded pile of stone widths that can fill every course; the same seed always gives the same pile.place(state, stoneIndex)lays that stone at the next free position of the current course; it is refused if it would overrun the wall width or put a joint directly over a joint of the course below. A course is complete when it is filled exactly, and the next course begins.undo(state)lifts the last stone of the current course.stone-wall/wall.test.mjsasserts each rule above: the same seed giving the same pile, a placement that overruns and one that stacks joints both refused, a course completing, undo, the course bonus, and the win and loss lines.bun testpasses for the new file.Files:
stone-wall/wall.js,stone-wall/wall.test.mjs. Risk: none outside the folder. Do not touchshell.js,index.html,town.jsorrounds.mjshere. Fits: a builder.Why this is rewritten: the first try (pull #225) went red only because the whole suite passed the deploy's 600 s limit while other checks ran at the same time, not because of a bug in the rules. #227 (pull #233) makes the suite cheaper. Done also looks like:
stone-wall/wall.test.mjsloads no page and starts no renderer or server: it calls the rules module directly and runs in under one second on its own (bun test stone-wall/wall.test.mjs). The pull states the measured time.