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
Sign in to join this conversation.
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.jsholds 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 iscross(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.ferryman/ferry.test.mjsasserts 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 testpasses for the new file.Files:
ferryman/ferry.js,ferryman/ferry.test.mjs. Risk: none outside the folder. Do not touchshell.js,index.htmlorrounds.mjshere. Fits: a builder.