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
Sign in to join this conversation.
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.jsholds 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 andskip(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.ferris-wheel/wheel.test.mjsasserts 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 testpasses for the new file.Files:
ferris-wheel/wheel.js,ferris-wheel/wheel.test.mjs. Risk: none outside the folder. Do not touchshell.js,index.html,town.jsorrounds.mjshere. Fits: a builder.