Public: anyone can read this; the crew can change it.

Migrated from github.com/amirmushichge/pixel-plays

Carousel rules: a tested `carousel/ride.js` where a rider on a turning carousel grabs brass rings from the dispenser at the right moment, from plain data #196

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This adds the Carousel rules as carousel/ride.js, with 9 tests in carousel/ride.test.mjs that pass under bun test carousel. It has no DOM and follows the pattern of sandcastle/tide.js. bun x tsc --noEmit only printed its help text, because the repo has no tsconfig, so there was no type check.

Notes

shipped production is serving it deploy ab54f53

opened this

This adds the Carousel rules as carousel/ride.js, with 9 tests in carousel/ride.test.mjs that pass under bun test carousel. It has no DOM and follows the pattern of sandcastle/tide.js.

bun x tsc --noEmit only printed its help text, because the repo has no tsconfig, so there was no type check. There is no scripts/gate.ts or scripts/fast.ts in this clone, so I ran neither.

Rules

  • Ride: start(seed) gives 10 turns, a dispenser at 180° and a 10-ring queue. Each ring is brass with a 30% chance, from the seed, and the same seed always gives the same queue.
  • Speed: it starts at 90°/s, rises 15°/s each turn and caps at 180°/s.
  • Grabbing: grab(state) takes the front ring only within ±20° of the dispenser. Outside that it is a miss (why: 'miss'). Either way the turn is spent, so a second grab is refused with why: 'spent'.
  • Skipped turns: a ring nobody grabs goes by at the end of its turn.
  • Scoring: iron scores 1 and brass scores 3. A brass grab within ±4° of the dispenser adds a bonus of 2.
  • Ending: after turn 10 the ride ends as won at 14 points or more, otherwise lost. It keeps the rings taken, the score and a line summary.
  • Long ticks: tick handles a large dt that crosses several turns, or the whole ride, in one call.

Tests They cover each rule in the issue:

  • the same seed giving the same queue;
  • the speed rising and capping;
  • a grab inside and outside the window;
  • one grab per turn;
  • iron, brass and centre scoring;
  • the win and loss lines.

Left alone There is no page and no catalogue entry, and I did not touch shell.js, index.html, town.js or rounds.mjs.

The numbers (10 turns, ±20° window, ±4° centre, 14 to win) are my picks. They are named constants at the top of ride.js, so a page or a rebalance can change them in one place.

To try it, run bun test carousel.

🤖 Generated with Claude Code

Closes #187

commented

This adds the Carousel rules as carousel/ride.js, with 9 tests in carousel/ride.test.mjs that pass under bun test carousel. It has no DOM and follows the pattern of sandcastle/tide.js.

bun x tsc --noEmit only printed its help text, because the repo has no tsconfig, so there was no type check. There is no scripts/gate.ts or scripts/fast.ts in this clone, so I ran neither.

Rules

  • Ride: start(seed) gives 10 turns, a dispenser at 180° and a 10-ring queue. Each ring is brass with a 30% chance, from the seed, and the same seed always gives the same queue.
  • Speed: it starts at 90°/s, rises 15°/s each turn and caps at 180°/s.
  • Grabbing: grab(state) takes the front ring only within ±20° of the dispenser. Outside that it is a miss (why: 'miss'). Either way the turn is spent, so a second grab is refused with why: 'spent'.
  • Skipped turns: a ring nobody grabs goes by at the end of its turn.
  • Scoring: iron scores 1 and brass scores 3. A brass grab within ±4° of the dispenser adds a bonus of 2.
  • Ending: after turn 10 the ride ends as won at 14 points or more, otherwise lost. It keeps the rings taken, the score and a line summary.
  • Long ticks: tick handles a large dt that crosses several turns, or the whole ride, in one call.

Tests They cover each rule in the issue:

  • the same seed giving the same queue;
  • the speed rising and capping;
  • a grab inside and outside the window;
  • one grab per turn;
  • iron, brass and centre scoring;
  • the win and loss lines.

Left alone There is no page and no catalogue entry, and I did not touch shell.js, index.html, town.js or rounds.mjs.

The numbers (10 turns, ±20° window, ±4° centre, 14 to win) are my picks. They are named constants at the top of ride.js, so a page or a rebalance can change them in one place.

To try it, run bun test carousel.

🤖 Generated with Claude Code

commented

The failed deploy isn't caused by my change, so I haven't pushed anything new.

  • What timed out: empire/page.test.mjs stalled in the forge's full test run. My pull only adds carousel/ride.js and carousel/ride.test.mjs, and none of the empire code or its tests is touched.
  • What I ran here: empire/page.test.mjs passes locally, 14 tests in 8.5 seconds. bun test carousel still passes with 9 tests.
  • Likely cause: the 600s ceiling looks like a slow or hung page test on the deploy machine, probably load or a browser-like wait. It is not a rule I can fix from carousel/.
  • Base branch: there are no new commits on main to rebase onto.

Editing the empire test or its timeout is outside this issue, which says "Risk: none outside the folder". I'd rather have a person decide that than change another game's tests in this pull. Please re-run the preview deploy. If empire/page.test.mjs hangs again, it needs its own issue.

Approved

Clean rules module in the same pattern as the other game rules (pure, seeded, no DOM, no timers, no dependencies). I read every line: no input reaches anything unsafe, non-finite seed/dt are coerced, refused grabs return the same state, and the tests cover seed determinism, speed cap, window edges, one grab per turn, scoring, and the win/lose line. The issue scoped this to the folder, so no page or catalogue entry is expected here. Minor, non-blocking: s.why stays at miss on the state after a later tick.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs