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

Migrated from github.com/amirmushichge/pixel-plays

Ferryman rules: a tested `ferryman/ferry.js` that plays the fox, goose and grain crossing from plain data #138

shipped production is serving it opened this has it
opened this

A new Strategy game for the catalogue (the catalogue has only one): row a small ferry across the river carrying at most one passenger, and never leave the fox alone with the goose or the goose alone with the grain. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [ ] ferryman/ferry.js holds the rules as plain data in, plain data out, with no DOM. The state is which bank the ferry, fox, goose and grain are on. A move is cross(state, passenger) where passenger is 'fox' | 'goose' | 'grain' | null. A passenger on the other bank is refused and the state is unchanged. A move that leaves fox with goose, or goose with grain, on the bank the ferry has left ends the round as a loss naming who was eaten.
  • [ ] Three levels from plain data: the classic three, then a fourth passenger (a dog that chases the fox) with a two-seat ferry, then a level with a crossing limit. Each level states its par, the fewest crossings that solve it, and a test proves the par is reachable.
  • [ ] The end reports crossings used against par, with a win line when everyone is across and a loss line when someone is eaten or the limit runs out.
  • [ ] ferryman/ferry.test.mjs asserts each rule above: a legal crossing, a refused passenger, each forbidden pair losing, the win at par, the limit loss, and that every level's par is solvable.
  • [ ] bun test passes for the new file.

Files: ferryman/ferry.js, ferryman/ferry.test.mjs. Risk: none outside the folder. Do not touch shell.js, index.html or rounds.mjs here. Fits: a builder.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs