Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Beach Huts rules: a tested `beach-huts/row.js` where you paint a seeded row of beach huts so no two neighbours share a colour, from limited tins, within par, in a two-file pull with a test file that runs in under a second #339
Reviewed pull #358 at its head: ticked beach-huts/row.js holds the rules as plain data in, plain data out, with no DOM, in the same UMD shape as ticket-booth/till.js (exporting BeachHuts in the browser). start(seed, level) gives the stated colours, the tins of each, the row of at least eight huts with which are pre-painted and locked, and the par. Randomness comes only from the seed, so the same seed gives the same row; no Math.random. Every generated level can be solved within par, and the test proves it for the first twenty seeds with a small solver in the test file.; The level is won when every hut is painted and clashes is empty, with a win line that reports strokes against par. Going over par ends the level with a loss line. undo(state) steps back one stroke.; beach-huts/row.test.mjs asserts each rule above: the same seed gives the same row; each refusal with its reason; a tin returned on repaint; clashes listed and cleared; the win line within par, the loss line over par; undo; and every one of the first twenty seeds solvable within par.; beach-huts/row.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 beach-huts/row.test.mjs). The pull states the measured time. bun test passes..
Left open after pull #358 landed: 1 unticked item remains (paint(state, hut, colour) paints one hut and counts a stroke; repainting a hut returns the old colour's tin. Each refuses with a reason and returns the same state: a hut that does not exist, a colour that does not exist, a locked hut, a colour with no tins left, or a game already over. Painting a hut the same colour as a neighbour is allowed but is shown in clashes(state), the list of neighbouring pairs that match.). The planner files each as its own issue and closes this one; a person may close it, tick what is done, or say what is left. Until then the crew does not pick it again.
Already done on main in 1b57138: beach-huts/row.js has paint(state, hut, colour) counting a stroke and returning the old tin on repaint, refusing no-such-hut, no-such-colour, locked, no-tins-left and game-over with the same state, and listing neighbour clashes in clashes(state); beach-huts/row.test.mjs asserts each (refusals, repaint tin, clash allowed and listed).
A new Puzzle game for the catalogue. A seeded row of seaside beach huts, some already painted and locked, must be painted so that no two neighbouring huts share a colour, using each colour no more than its stated tin count, within a par of brush strokes. Rules only: no page and no catalogue entry yet.
Done looks like:
Files:
beach-huts/row.js,beach-huts/row.test.mjs: a two-file pull. Risk: none outside the folder. Do not touchshell.js,index.html,town.js,rounds.mjs,forge.json,scripts/,playtest.test.mjsorserve.test.mjshere. Fits: a builder.