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 #375
Sign in to join this conversation.
A new Timing game for the catalogue. A chalk court of numbered squares, laid out by a seed; a power meter sweeps up and down by tick, and you toss your stone when it reads the square you need, then hop the court in order without landing on the stone's square. Rules only: no page and no catalogue entry yet.
Done looks like:
hopscotch/court.jsholds the rules as plain data in, plain data out, with no DOM, in the same UMD shape asmilk-churns/churns.js(exportingHopscotchin the browser).start(seed)gives the same court (at least eight squares, some doubles side by side), a number of turns and the meter's period for the same seed;meter(state, tick)is a pure function of the tick. No Math.random.toss(state)lands the stone on the square the meter reads; landing on the square you need moves you on to hopping, any other square costs a turn.hop(state, square)accepts only the next square in order and never the stone's square. Each refuses with a reason and returns the same state: a hop out of order, a hop onto the stone, a toss while hopping, a hop before a toss, or a game already over; a refusal never costs a turn.restart(state)gives the same seed fresh. The state reports square needed, turns, phase and score for the HUD; no call mutates its input.hopscotch/court.test.mjsasserts each rule above: the same seed gives the same court and meter; a toss at the needed reading, one reading either side; a missed toss costing a turn; hopping in order and the stone's square skipped; each refusal with its reason; both endings with their end lines; restart; no input is mutated.hopscotch/court.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 hopscotch/court.test.mjs). The pull states the measured time.bun testpasses.Files:
hopscotch/court.js,hopscotch/court.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.