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

Migrated from github.com/amirmushichge/pixel-plays

Weathervane rules: a tested `weathervane/vanes.js` where you turn linked rooftop weathervanes so every one points the level's wind within par, in a two-file pull with a test file that runs in under a second #373

open not picked up yet opened this
opened this

A new Puzzle game for the catalogue. A row of village rooftops each carries a weathervane pointing one of eight compass directions; turning one vane a step clockwise also turns the vanes it is linked to, and you must set every vane to the level's wind within par. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [ ] weathervane/vanes.js holds the rules as plain data in, plain data out, with no DOM, in the same UMD shape as milk-churns/churns.js (exporting Weathervane in the browser). It has at least six hand-written levels, each with a name, the vanes' starting directions (0-7), the links (which vanes each vane also turns), the target wind, a solution (a list of vane indices) and a par; start(level) gives that level fresh and falls back to level 0 for an unknown one. No Math.random.
  • [ ] turn(state, i) turns vane i and each vane linked to it one step clockwise, wrapping 7 to 0, and counts a move. It refuses with a reason and returns the same state for an index that is not a whole number in range, a vane that is pinned in that level, or a game already over; a refusal never costs a move.
  • [ ] Every vane pointing the target wind wins with a line naming moves against par (on par, under par or over par). undo(state) restores the exact previous state and restart(state) gives the level fresh. The state reports level, moves, par, each vane's direction and the target for the HUD; no call mutates its input.
  • [ ] weathervane/vanes.test.mjs asserts each rule above: each level's stated solution wins within par; a turn moves exactly the vane and its links and wraps 7 to 0; each refusal with its reason; undo restores the exact previous state; the win line at, under and over par; restart; no input is mutated.
  • [ ] weathervane/vanes.test.mjs loads no page and starts no renderer or server: it calls the rules module directly and runs in under one second on its own (bun test weathervane/vanes.test.mjs). The pull states the measured time. bun test passes.

Files: weathervane/vanes.js, weathervane/vanes.test.mjs: a two-file pull. Risk: none outside the folder. Do not touch shell.js, index.html, town.js, rounds.mjs, forge.json, scripts/, playtest.test.mjs or serve.test.mjs here. Fits: a builder.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs