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

Migrated from github.com/amirmushichge/pixel-plays

Allotment rules: a tested `allotment/plot.js` that plants a season of crops on a grid and scores neighbours from plain data #157

shipped production is serving it opened this has it
opened this

A new Strategy game for the catalogue (the catalogue has only one): plant a small allotment over one season, where each crop scores by what grows beside it. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [ ] allotment/plot.js holds the rules as plain data in, plain data out, with no DOM. start(seed) makes an empty grid of a stated size, a stated number of turns, and a seeded hand of seed packets; the same seed always gives the same hand. plant(state, x, y) puts the next packet's crop in an empty bed and refuses a filled bed or a cell off the grid. There are at least four crops, each with one stated neighbour rule (for example: beans score for each touching sweetcorn, carrots lose for each touching onion).
  • [ ] score(state) totals the grid from those rules alone. When the turns run out or the grid is full, the end reports the score and the best, with a win line at or above a stated target and a loss line below it.
  • [ ] allotment/plot.test.mjs asserts each rule above: the same seed giving the same hand, a refused plant on a filled bed and off the grid, each crop's neighbour rule on a hand-built grid, the game ending when turns run out, and the win and loss lines.
  • [ ] bun test passes for the new file.

Files: allotment/plot.js, allotment/plot.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