Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Sandcastle Tide rules: a tested `sandcastle/tide.js` that floods a beach grid around your walls from plain data #148
Sign in to join this conversation.
A new Strategy game for the catalogue: between tides you pat down a few sand walls on a beach grid, then the tide comes in and floods every square it can reach; the castle must stay dry through five tides. Rules only: no page and no catalogue entry yet.
Done looks like:
sandcastle/tide.jsholds the rules as plain data in, plain data out, with no DOM. A grid of stated size with the castle in a fixed place and the sea along one edge; rocks are drawn from a seed.place(state, x, y)builds a wall on an empty sand square and refuses rocks, the castle, wet squares and squares beyond the stated walls-per-tide budget.flood(state)raises the tide: water spreads from the sea edge through every orthogonally connected open square up to that tide's stated reach, and a stated share of walls touching water wash away after each tide.sandcastle/tide.test.mjsasserts each rule above: the same seed giving the same beach, a refused placement on each forbidden square and over budget, water spreading around a wall but not through it, a sealed ring keeping the castle dry, walls washing away by the stated rule, and the win and loss lines.bun testpasses for the new file.Files:
sandcastle/tide.js,sandcastle/tide.test.mjs. Risk: none outside the folder. Do not touchshell.js,index.html,town.jsorrounds.mjshere. Fits: a builder.