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
Sign in to join this conversation.
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.jsholds the rules as plain data in, plain data out, with no DOM, in the same UMD shape asmilk-churns/churns.js(exportingWeathervanein 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, asolution(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 vaneiand 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.undo(state)restores the exact previous state andrestart(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.mjsasserts 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.mjsloads 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 testpasses.Files:
weathervane/vanes.js,weathervane/vanes.test.mjs: a two-file pull. Risk: none outside the folder. Do not touchshell.js,index.html,town.js,rounds.mjs,forge.json,scripts/,playtest.test.mjsorserve.test.mjshere. Fits: a builder.