Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Bunting rules: a tested `bunting/line.js` that hangs flags on a string so no two neighbours match, from plain data #189
Sign in to join this conversation.
A new Strategy game for the catalogue: the village green has strings of bunting tied between posts and lamps; hang a flag on every hook so no two flags that touch along a string, or where strings cross, share a pattern. Rules only: no page and no catalogue entry yet.
Done looks like:
bunting/line.jsholds the rules as plain data in, plain data out, with no DOM.start(seed, level)lays out a stated set of hooks, which hooks neighbour each other, a few flags already fixed, and a stated number of patterns; the same seed and level always give the same layout, and every layout can be finished (build it from a finished hanging, then take flags down).hang(state, hook, pattern)puts a flag on an empty hook and counts one move; hanging on a fixed hook, an unknown hook or with an unknown pattern is refused.take(state, hook)removes a flag that is not fixed.clashes(state)lists every pair of neighbouring hooks that share a pattern.bunting/line.test.mjsasserts each rule above: the same seed giving the same layout, every generated level being finishable, refused hangs,takerefusing a fixed flag,clashesfinding a clash and clearing when it is fixed, the level advancing, and the win and loss lines.bun testpasses for the new file.Files:
bunting/line.js,bunting/line.test.mjs. Risk: none outside the folder. Do not touchshell.js,index.html,town.jsorrounds.mjshere. Fits: a builder.