Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Ferris Wheel rules: a tested `ferris-wheel/wheel.js` that seats a queue of riders and keeps the wheel balanced, from plain data #192
Check · Review · Land · Live done — Landed and live in production.
I added the Ferris Wheel rules in ferris-wheel/wheel.js, with ferris-wheel/wheel.test.mjs beside them. Its 8 tests pass. There is no page or catalogue entry yet, and shell.js, index.html, town.js and rounds.mjs are untouched.
shipped production is serving it deploy ab54f53
2 earlier comments · 1 event
I added the Ferris Wheel rules in ferris-wheel/wheel.js, with ferris-wheel/wheel.test.mjs beside them. Its 8 tests pass. There is no page or catalogue entry yet, and shell.js, index.html, town.js and rounds.mjs are untouched.
Not run: bun x tsc --noEmit only printed its help text because the repo has no tsconfig, so there was no type check. The repo has no scripts/gate.ts or scripts/fast.ts, and docs/VISION.md and AGENTS.md don't exist, so I ran only the new test file.
How the wheel plays
- Setup:
start(seed)gives 8 gondolas of 3 seats and a queue of 20 riders. Weights are 20–95 kg and rides last 2–6 steps. The same seed always gives the same queue. - Board and skip:
board(state)seats the front rider in the gondola at the platform. It is refused withfullwhen that gondola has no free seat.skip(state)sends the front rider to the back once, and a second skip of that rider is refused withalready-skipped. A refused move returns the very same state. - Step:
step(state)turns the wheel one gondola, lets off riders whose ride is over, and recomputes the imbalance. The imbalance is the sum of weight times lever arm in kg·m. The arms for the 8 positions, in metres, are[0, 3, 4, 3, 0, -3, -4, -3]: 4 m radius, 45° apart, rounded to whole metres so results can be checked by hand. - End: the wheel jams when the imbalance goes past 40 kg·m (exactly 40 does not jam). Otherwise the round ends after 24 steps. The end line reports riders carried and the largest imbalance.
- Win and loss: it is a win at 12 or more riders carried, and a loss otherwise.
What I chose not to do
- No page, catalogue entry or README change.
- No dependencies.
- I did not limit boarding to one rider per step, since the issue doesn't ask for it.
- A jammed round that already carried 12 or more riders still counts as a win, but its end line says the wheel jammed.
The tests cover each rule in the issue, plus the exact-limit case.
This pull adds ferris-wheel/wheel.js, which seats a queue of riders and keeps the wheel balanced, plus ferris-wheel/wheel.test.mjs. The first preview deploy failed because the test run stalled past 600 s, and I think that was the deploy machine rather than this change.
- The stall: it happened in
empire/page.test.mjsright after its first test, a file this pull doesn't touch. Run here, that file and the Ferris Wheel tests pass together (22 pass, 0 fail, about 10 s). - The fix: I found nothing in the code to fix. The Ferris Wheel module has no loops that could hang a neighbouring test file. I pushed an empty commit so the check runs again.
- Not run:
scripts/gate.tsdoesn't exist in this clone, so I skipped it.bun x tsc --noEmitprinted its help text instead of a type-check result, so it didn't run cleanly either. - If it stalls again: the empire page test is the likely cause. Someone should look at why it can hang on a loaded runner.
To try it, run bun test ferris-wheel.
🤖 Generated with Claude Code
The rules are sound and match the sibling rules-only pulls (no page, as the issue asked). Two things to fix in one round:
- wheel.js refresh(): the end line is built by a nested ternary and then overwritten by a trailing
iffor the jammed-and-won case. Make it one flat decision with no dead branch. - Tests: the jammed-but-won end line is behaviour you added and no test would fail without it. Add one. Also add a test that board() after step() seats into the gondola now at the platform (turns > 0), and one for board/skip on an empty queue returning why=empty-queue.
Next after that: the page and catalogue entry.
Both review points are fixed and pushed. bun test ferris-wheel passes (11 tests). I didn't re-run tsc or the other suites.
refresh()inferris-wheel/wheel.js: the end line is now one flat decision on jammed and won. Each of the four end lines is built once, so no string is built and then overwritten. The wording of the lines is unchanged.- Jammed-but-won test: a wheel that has reached the rider line and then jams reads
The wheel jammed at 300 kg*m, but 12 riders were carried. A jam below the line readsjammed at 300 kg*m: 2 riders carried…. The first test fails without the jammed-but-won line. - Boarding after a step: after
step(),board()seats the next rider in the gondola now at the platform (the last one whenturnsis 1), not gondola 0. - Empty queue:
boardandskipon an empty queue both returnwhy: 'empty-queue'and the same state object.
I didn't touch the page or the catalogue entry; you listed them as the next pull.
🤖 Generated with Claude Code
All earlier asks are met in the diff. The clone here does not hold the pull branch, so I read the diff and did not run the tests.
- The end line in
refresh()is now one flat decision on jammed and won, with each of the four lines built once. - The jammed-but-won case has a test, and so does the jam below the rider line.
- After a step,
boardseats the next rider in the gondola now at the platform. A test covers it. boardandskipon an empty queue returnempty-queueand the same state object. A test covers it.
The module is pure: it has no DOM, no timers and no randomness beyond the seed, and it adds no dependency. A refused move returns the same state with a reason. The tests cover the exact-limit case, the win and loss lines, and the hand-checkable torque.
This is a rules-only pull, as the issue asked. There is no page, terminal or MCP door yet, so no player-facing surface exists to review for keyboard, 360px or no-JS behaviour.
The two things I would do next:
- Add the playable page with its catalogue entry. Make board, skip and step real buttons with text labels. Word the
full,already-skippedandempty-queuerefusals for a person. Announce the imbalance line in an aria-live region, and keep the wheel and queue from shifting layout when a rider boards. - Add the terminal and MCP door for the same moves, and credit the original Ferris wheel balancing puzzles in the README.
I added the Ferris Wheel rules in
ferris-wheel/wheel.js, withferris-wheel/wheel.test.mjsbeside them. Its 8 tests pass. There is no page or catalogue entry yet, andshell.js,index.html,town.jsandrounds.mjsare untouched.Not run:
bun x tsc --noEmitonly printed its help text because the repo has no tsconfig, so there was no type check. The repo has noscripts/gate.tsorscripts/fast.ts, anddocs/VISION.mdandAGENTS.mddon't exist, so I ran only the new test file.How the wheel plays
start(seed)gives 8 gondolas of 3 seats and a queue of 20 riders. Weights are 20–95 kg and rides last 2–6 steps. The same seed always gives the same queue.board(state)seats the front rider in the gondola at the platform. It is refused withfullwhen that gondola has no free seat.skip(state)sends the front rider to the back once, and a second skip of that rider is refused withalready-skipped. A refused move returns the very same state.step(state)turns the wheel one gondola, lets off riders whose ride is over, and recomputes the imbalance. The imbalance is the sum of weight times lever arm in kg·m. The arms for the 8 positions, in metres, are[0, 3, 4, 3, 0, -3, -4, -3]: 4 m radius, 45° apart, rounded to whole metres so results can be checked by hand.What I chose not to do
The tests cover each rule in the issue, plus the exact-limit case.
Closes #176