Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Hopscotch rules: a tested `hopscotch/court.js` where you toss a stone onto a seeded hopscotch court and hop the squares in order, skipping the stone's square, before your turns run out, in a two-file pull with a test file that runs in under a second #380
Merged 10h 55m ago, live in production
This adds the Hopscotch rules as a two-file pull, hopscotch/court.js and hopscotch/court.test.mjs. It adds no page or catalogue entry. bun test hopscotch/court.test.mjs passes 11 of 11 in about 0.017 s wall time (12 ms reported by bun).
-
Reviews
ApprovedRules-only pull, no page, so there is no first paint, keyboard or phone surface to judge; the preview shows nothing new, which is what the issue asked for. I read court.js against the issue and ran the test file: 11 pass, 12 ms. The UMD shape matches churns.js, there is no Math.random, and refusals return the identical state object with a reason and no turn cost. I traced the edge cases (stone on square 1 or on N, a loss on the last turn, a restart) and they hold.
Two things I would do next:
- When the page lands, give it a visible, non-colour cue for the stone's square and the meter reading, plus a keyboard path to Toss and Hop and a 44px touch target per square. Map the reasons (on-stone, out-of-order, no-toss, already-hopping, unknown-square, game-over) to person-worded messages. Do not show the raw codes.
- Add one line in the header comment crediting hopscotch as a traditional children's street game, in keeping with the direction to name origins. Also make meter return 1 for a non-finite tick, since meter(s, NaN) currently returns NaN.
-
Checks
shipped production is serving it deploy 7b8dc66
-
History
- Add the Hopscotch rules and their tests: seeded court, tick-driven meter, toss and hop with refusals (#375) 46a21d5
- Merge pull request #372 from vesper/367-add-beach-huts-the-playable-page-and-its ab54f53
- Give Empire's place-a-house playtest 30 s like its neighbours: 40 game seconds tripped the 5 s default on a loaded deploy machine (#367) 54a2ba5
- Give each game's playtests 30 s plus 300 ms per round second: a loaded deploy machine tripped the 15 s budget on beekeeper and bell-tower (#367) 82c5c9e
- Stop drawing in Chestnut Roast's round-to-the-end tests: they read only HUD text, so they fit the deploy's 5 s timeout (#367) 44de320
- Let a scripted round keep drawing when its game lays out its panes in draw: stained-glass reads anchors the picture sets (#367) d727fc7
- Stop drawing during scripted rounds: they read only text, so the suite fits the deploy's time (#367) 5130f4c
- Keep the test run under the deploy's 2-core limit: one GC marker, no concurrent JIT or GC (#367) 708b5cb
- Re-run the preview deploy: the suite passes in full locally (1991 tests, 340 s) 7a87984
- Add Beach Huts: the playable page and its place in the catalogue, on the rules in `beach-huts/row.js` (#367) 6da49a4
- Add Cake Stall: the playable page and its place in the catalogue, on the rules in `cake-stall/order.js` (#371) 5b5fb07
- Cake Stall rules: a tested `cake-stall/order.js` where you memorise a seeded order of cake layers shown for a few ticks and stack them back in that order, in a two-file pull with a test file that runs in under a second (#366) d61fa3f
- Add Apple Bobbing: the playable page and its place in the catalogue, on the rules in `apple-bobbing/tub.js` (#365) 4d4af0c
- Cheese Rolling rules: a tested `cheese-rolling/hill.js` where you chase a seeded rolling cheese down a steep hill, dodging tussocks, and catch it before the bottom, in a two-file pull with a test file that runs in under a second (#359) 8b024c2
- 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) 1b57138
- 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
This adds the Hopscotch rules as a two-file pull, hopscotch/court.js and hopscotch/court.test.mjs. It adds no page or catalogue entry. bun test hopscotch/court.test.mjs passes 11 of 11 in about 0.017 s wall time (12 ms reported by bun). The test file calls the rules module directly and loads no page, renderer or server. I did not run the full bun test, and the repo has no scripts/gate.ts, so there was no gate run.
The rules
- Shape:
court.jshas the same UMD shape aschurns.jsand exportsHopscotchin the browser. It uses plain data in and out, a seeded mulberry32 generator, and noMath.random. start(seed): it gives the same court, turns and meter period for the same seed. The court has 8–11 squares in order, always with at least one side-by-side double. There are 3–5 turns, and the period is set so every square can be read.meter(state, tick): a pure triangle wave of the tick that reads 1 to N.- Ticks:
toss(state)takes no tick argument, so the state carries a tick and I addedtick(state, n)to advance it. The page will need to call it as the meter sweeps. toss(state): it lands the stone on the square the meter reads. Landing on the needed square starts hopping. Any other square costs one turn, and the last turn lost ends the game.hop(state, square): it accepts only the next square in order and never the stone's square. Finishing the round clears the needed square and moves the need on to the next. Clearing square N wins.- Refusals: each returns the same state object with a reason and costs no turn. The reasons are
no-toss,out-of-order,on-stone,unknown-square,already-hoppingandgame-over.unknown-squareis one I added for a square that is not an integer in range. - End lines: "You win: N squares cleared, T turns left" and "Out of turns: C of N squares cleared, T turns left".
restart(state): it gives the same seed fresh.- State fields:
need,turns,phase,cleared,scoreandline. - Score: it is
cleared*100 + turns*10, which the issue did not specify.
Tests
- They cover each rule in the issue: determinism, the toss at the needed reading and one either side, a missed toss costing a turn, in-order hopping with the stone skipped, every refusal, both endings, restart, and that nothing mutates frozen input.
- Mutation: the no-mutation test freezes the state and checks every call.
Not done: no shell.js, index.html, town.js, rounds.mjs, forge.json, scripts/, playtest.test.mjs or serve.test.mjs changes, and no UI.
To try it: bun test hopscotch/court.test.mjs.
🤖 Generated with Claude Code
This adds the Hopscotch rules as a two-file pull,
hopscotch/court.jsandhopscotch/court.test.mjs. It adds no page or catalogue entry.bun test hopscotch/court.test.mjspasses 11 of 11 in about 0.017 s wall time (12 ms reported by bun). The test file calls the rules module directly and loads no page, renderer or server. I did not run the fullbun test, and the repo has noscripts/gate.ts, so there was no gate run.The rules
court.jshas the same UMD shape aschurns.jsand exportsHopscotchin the browser. It uses plain data in and out, a seeded mulberry32 generator, and noMath.random.start(seed): it gives the same court, turns and meter period for the same seed. The court has 8–11 squares in order, always with at least one side-by-side double. There are 3–5 turns, and the period is set so every square can be read.meter(state, tick): a pure triangle wave of the tick that reads 1 to N.toss(state)takes no tick argument, so the state carries a tick and I addedtick(state, n)to advance it. The page will need to call it as the meter sweeps.toss(state): it lands the stone on the square the meter reads. Landing on the needed square starts hopping. Any other square costs one turn, and the last turn lost ends the game.hop(state, square): it accepts only the next square in order and never the stone's square. Finishing the round clears the needed square and moves the need on to the next. Clearing square N wins.no-toss,out-of-order,on-stone,unknown-square,already-hoppingandgame-over.unknown-squareis one I added for a square that is not an integer in range.restart(state): it gives the same seed fresh.need,turns,phase,cleared,scoreandline.cleared*100 + turns*10, which the issue did not specify.Tests
Not done: no
shell.js,index.html,town.js,rounds.mjs,forge.json,scripts/,playtest.test.mjsorserve.test.mjschanges, and no UI.To try it:
bun test hopscotch/court.test.mjs.🤖 Generated with Claude Code
Closes #375