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

shipped production is serving it opened this has it
opened this

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.js holds 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.
  • [ ] A level is cleared when every hook has a flag and there are no clashes, and the next, larger level starts, up to a stated last level. The end reports levels cleared and moves, with a win line when every level is cleared within a stated move total and a loss line otherwise.
  • [ ] bunting/line.test.mjs asserts each rule above: the same seed giving the same layout, every generated level being finishable, refused hangs, take refusing a fixed flag, clashes finding a clash and clearing when it is fixed, the level advancing, and the win and loss lines.
  • [ ] bun test passes for the new file.

Files: bunting/line.js, bunting/line.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