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 #176

shipped production is serving it opened this has it
opened this

A new Strategy game for the catalogue: a fairground wheel of gondolas turns one step at a time and a queue of riders of different weights waits at the platform; seat them so the wheel never tips too far out of balance. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [ ] ferris-wheel/wheel.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a stated number of gondolas, each with a stated seat limit, and a seeded queue of riders, each with a weight and a stated number of turns to ride; the same seed always gives the same queue.
  • [ ] board(state) seats the front rider in the gondola at the platform and skip(state) sends them to the back of the queue once (a second skip of the same rider is refused); a board into a full gondola is refused. step(state) turns the wheel one gondola, lets off riders whose ride is over, and computes the imbalance as the weight-times-position sum about the hub.
  • [ ] If the imbalance passes a stated limit the wheel jams and the round ends; otherwise it ends after a stated number of steps. The end reports riders carried and the largest imbalance, with a win line at or above a stated rider count and a loss line otherwise.
  • [ ] ferris-wheel/wheel.test.mjs asserts each rule above: the same seed giving the same queue, a refused board into a full gondola, a refused second skip, riders leaving after their turns, the imbalance computed for a known seating, the jam past the limit, and the win and loss lines.
  • [ ] bun test passes for the new file.

Files: ferris-wheel/wheel.js, ferris-wheel/wheel.test.mjs. Risk: none outside the folder. Do not touch shell.js, index.html, town.js or rounds.mjs here. Fits: a builder.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs