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 #358
Merged 30d 21h ago, live in production
Beach Huts rules are in beach-huts/row.js with beach-huts/row.test.mjs, and nothing else is touched. bun test beach-huts/row.test.mjs passes 8 tests in 52 ms (0.059 s wall). I didn't run the full bun test or bun x tsc --noEmit.
-
Reviews
Changes requested — before the latest pushThe rules are sound and match the issue on every box except one gap: the
same-colourrefusal inpaint(row.js, theold.colour === colourline) is new behaviour with no test. Delete that line and the whole suite still passes, so it breaks the rule that every behaviour added has a test that would fail without it.Fix, in one round:
- Add a test to
row.test.mjs: paint a bare hut, then paint it the same colour. Assertrefused(s1, paint(s1, i, a), "same-colour")and that strokes and tins are unchanged. Or drop the refusal, since the issue did not list it. Keeping it with a test is fine. - Tidy the last assertions in the over-par test.
paint(start(1,1), bare(start(1,1)), "red")reads like a stray check. It also depends on red having a tin for seed 1. Move it into its own test, and uses.colourswith a tin check instead of a hard-codedred.
No preview page is expected for a rules-only pull, and the 52 ms time is stated.
ApprovedBoth earlier asks are met:
same-colournow has a test that fails without the refusal (it checks strokes and tins unchanged), and the hard-codedredassertion is gone in favour of a colour taken froms.coloursthat still has a tin. I could not run the suite here because my clone is at base, so I read the diff only. The rules read cleanly: seeded mulberry32 with no Math.random, plain data in and out, refusals return the identical state, and the solver test covers 20 seeds at all 5 levels.Next, in order:
- Build the playable page and catalogue entry on
BeachHuts. Show clashes with a shape or label as well as colour, so colour-blind players can use it, and make huts reachable by keyboard. - Non-blocking: name
same-colourin the issue or README rules text so the extra refusal reason is documented.
- Add a test to
-
Checks
shipped production is serving it deploy 7b8dc66
-
History
- Beach Huts: test the same-colour refusal; move the undo check into its own test f77f6ae
- Beach Huts rules: a tested beach-huts/row.js with seeded rows, tins, par, clashes and undo beb124a
- Apple Bobbing rules: a tested `apple-bobbing/tub.js` where you dunk for seeded bobbing apples at the top of their bob before your breaths run out, in a two-file pull with a test file that runs in under a second (#357) e1c635e
- Add Bumper Cars: the playable page and its place in the catalogue, on the rules in `bumper-cars/floor.js` (#351) d15ea60
- Milk Churns rules: a tested `milk-churns/churns.js` where you pour milk between three churns to leave an exact amount within par, in a two-file pull with a test file that runs in under a second (#353) a9d3069
- Add Tide Crossing: the playable page and its place in the catalogue, on the rules in `tide-crossing/causeway.js` (#352) 5ac2d31
- Add Pumpkin Patch: the playable page and its place in the catalogue, on the rules in `pumpkin-patch/plots.js` (#341) 0145828
- Add Village Darts: the playable page and its place in the catalogue, on the rules in `village-darts/board.js` (#347) 2688fb5
- Add Carrot Pull: the playable page and its place in the catalogue, on the rules in `carrot-pull/bed.js` (#348) 52f104e
- Add Ticket Booth: the playable page and its place in the catalogue, on the rules in `ticket-booth/till.js` (#342) ec07843
- Tide Crossing rules: a tested `tide-crossing/causeway.js` where you step across a stone causeway to the island before the tide covers your path, within par, in a two-file pull with a test file that runs in under a second (#346) 0a97afa
- Village Darts rules: a tested `village-darts/board.js` where you count down from 301 and finish on a double against a seeded rival, in a two-file pull with a test file that runs in under a second (#337) c4973b7
- Carrot Pull rules: a tested `carrot-pull/bed.js` where you pull carrots when ripe before a seeded rabbit nibbles them, in a two-file pull with a test file that runs in under a second (#340) cfd8dbc
- Add Fence Posts: the playable page and its place in the catalogue, on the rules in `fence-posts/field.js` (#335) 76f43b2
- Bumper Cars rules: a tested `bumper-cars/floor.js` where you steer a car on a walled floor and shove three seeded rivals into the wall without a head-on bump, from plain data, in a two-file pull with a test file that runs in under a second (#336) 8728d37
- Ticket Booth rules: a tested `ticket-booth/till.js` where you hand exact change from a limited till to a seeded queue of pier visitors, in a two-file pull with a test file that runs in under a second (#330) 4143ff3
- Add Welly Toss: the playable page and its place in the catalogue, on the rules in `welly-toss/throw.js` (#334) f495867
- Welly Toss rules: a tested `welly-toss/throw.js` where you swing a boot and let go at the right moment of the arc to land it past the marker flags, against a seeded crosswind, from plain data, in a two-file pull with a test file that runs in under a second (#323) 79548c6
- Pumpkin Patch rules: a tested `pumpkin-patch/plots.js` where each pour waters a plot and its neighbours to bring every plot to exactly its need within par, in a two-file pull with a test file that runs in under a second (#326) 79372dd
- Add Chestnut Roast: the playable page and its place in the catalogue, on the rules in `chestnut-roast/pan.js` (#311) 218a05c
2 earlier comments
Beach Huts rules are in beach-huts/row.js with beach-huts/row.test.mjs, and nothing else is touched. bun test beach-huts/row.test.mjs passes 8 tests in 52 ms (0.059 s wall). I didn't run the full bun test or bun x tsc --noEmit. The repo has no scripts/gate.ts.
What changed
- Module:
row.jsis UMD liketill.jsand exportsBeachHuts. Every call returns{ok, state, why}, and a refusal returns the very same state object. start(seed, level):- A hidden colouring with no neighbouring match is drawn from a mulberry32 stream, so there is no
Math.random. - Some huts are locked to that colouring, and at least three stay open.
- The row has 8 + level huts (level clamps to 1–5), with 3 colours and a 4th from level 3.
- Each tin holds what the open huts need plus at most one spare.
- Par is the open huts plus one or two strokes of slack.
- Every level is solvable within par by construction.
- A hidden colouring with no neighbouring match is drawn from a mulberry32 stream, so there is no
paint(state, hut, colour): counts a stroke and returns the old colour's tin on repaint.- Its refusal reasons are
no-such-hut,no-such-colour,locked,no-tins-leftandgame-over. - A clash is allowed and shows up in
clashes(state).
- Its refusal reasons are
- Win and loss: the win line is "Row painted: N strokes against par P". Going over par gives "Over par: N strokes against par P, the row is not done".
undo(state): steps back one stroke, and refuses withnothing-to-undowhen there is nothing to undo.- Tests: they cover each rule in the issue. A small backtracking solver checks the first twenty seeds at every level, and the solved state has to win within par.
Choices to look at
- Same-colour repaint: repainting a hut the colour it already is refuses with
same-colour, because a stroke would be wasted. The issue didn't list this reason. - Undo after a loss: undo works from a lost state and restores play, so a player who overshoots isn't stuck.
Not done: no page, no catalogue entry, and no changes to shell.js, index.html, town.js, rounds.mjs, forge.json or the tests outside the folder.
🤖 Generated with Claude Code
Both review points are fixed and pushed. The same-colour refusal now has a test, and the stray red check has its own test.
same-colourtest: "painting a hut the colour it already is refuses…" paints a bare hut, then paints it the same colour. It assertsrefused(s1, paint(s1, i, a), "same-colour"), that strokes stay at 1, and that tins are unchanged. I deleted theold.colour === colourline to check the test bites: it then fails, and restoring the line makes it pass again. I kept the refusal rather than dropping it.- Over-par test: I removed the two trailing assertions, including the hard-coded
redone. They now live in "undo of a single stroke restores the starting state exactly". That test picks a colour froms.coloursthat still has a tin, and checksundoreturns exactly the starting state.
row.test.mjs passes, 10 tests in about 30 ms. bun x tsc --noEmit printed only its usage text, apparently because the repo has no tsconfig.json, so it didn't type-check anything. I didn't run scripts/gate.ts.
Left #339 open: 1 unticked item remain (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.).
Beach Huts rules are in
beach-huts/row.jswithbeach-huts/row.test.mjs, and nothing else is touched.bun test beach-huts/row.test.mjspasses 8 tests in 52 ms (0.059 s wall). I didn't run the fullbun testorbun x tsc --noEmit. The repo has noscripts/gate.ts.What changed
row.jsis UMD liketill.jsand exportsBeachHuts. Every call returns{ok, state, why}, and a refusal returns the very same state object.start(seed, level):Math.random.paint(state, hut, colour): counts a stroke and returns the old colour's tin on repaint.no-such-hut,no-such-colour,locked,no-tins-leftandgame-over.clashes(state).undo(state): steps back one stroke, and refuses withnothing-to-undowhen there is nothing to undo.Choices to look at
same-colour, because a stroke would be wasted. The issue didn't list this reason.Not done: no page, no catalogue entry, and no changes to
shell.js,index.html,town.js,rounds.mjs,forge.jsonor the tests outside the folder.🤖 Generated with Claude Code
Closes #339