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
Merged 31d 23h ago, 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.
-
Reviews
Changes requested — before the latest pushThe 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.
ApprovedAll 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.
- wheel.js refresh(): the end line is built by a nested ternary and then overwritten by a trailing
-
Checks
shipped production is serving it deploy ab54f53
-
History
- Ferris Wheel: one flat end-line decision, and tests for jammed-but-won, boarding after a step, and an empty queue f1341ef
- Re-run the check: the empire page test stalled in the deploy, and passes here with the wheel tests e5e674f
- Ferris Wheel rules: a tested ferris-wheel/wheel.js that seats a queue of riders and keeps the wheel balanced, from plain data (#176) c526521
- Add Sandcastle Tide: the playable page and its place in the catalogue, on the rules in `sandcastle/tide.js` (#183) 62ed252
- Market Barrow rules: a tested `market-barrow/barrow.js` that buys and sells a barrow of goods across village stalls over ten days, from plain data (#172) dcd7a2d
- Add Tower Duel: the playable page and its place in the catalogue, on the rules in `tower-duel/duel.js` (#156) 651fe84
- Lily Pond rules: a tested `lily-pond/pond.js` where a frog must hop every lily pad once before they sink, from plain data (#173) a189dc4
- Sandcastle Tide rules: a tested `sandcastle/tide.js` that floods a beach grid around your walls from plain data (#164) 8a56e9e
- Shunting Yard rules: a tested `shunting-yard/yard.js` that sorts numbered wagons through sidings from plain data (#171) 0ac2869
- Hedge Maze rules: a tested `hedge-maze/maze.js` that carves and walks a seeded maze from plain data (#165) ee4504b
- Add Ferryman: the playable page and its place in the catalogue, on the rules in `ferryman/ferry.js` (#160) c673ad1
- Allotment rules: a tested `allotment/plot.js` that plants a season of crops on a grid and scores neighbours from plain data (#170) 8339194
- Add Lock Keeper: the playable page and its place in the catalogue, on the rules in `lock-keeper/lock.js` (#159) e7a1429
- Add Hoopla Stall: the playable page and its place in the catalogue, on the rules in `hoopla/hoop.js` (#155) 2a3861d
- Open the home page on the isometric town: tap a building to play its game (#153) c4f9ad3
- Lock Keeper rules: a tested `lock-keeper/lock.js` that works boats through a flight of canal locks from plain data (#154) 18627a4
- Add Seed Packets: turn over the packets on the potting bench and match every pair before the gardener comes back (#136) 1bcb5fd
- Ferryman rules: a tested `ferryman/ferry.js` that plays the fox, goose and grain crossing from plain data (#152) 2081d2f
- Hoopla Stall rules: a tested `hoopla/hoop.js` that plays a whole game from plain data (#147) 3f33d3f
- Tower Duel rules: a tested `tower-duel/duel.js` that plays a whole two-lane card battle from plain data (#143) a4bac34
2 earlier comments
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
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
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