Missionaries & Cannibals
Three missionaries and three cannibals must cross a river in a boat that holds two. On a bank where any missionaries are present, cannibals may never outnumber them. Can one good move at a time add up to a plan? And how much of the answer depends on what we tell Jev?
Bank counts, boat side, the legal moves and the state each one leads to. What the exhibit sends by default. No memory.
Three missionaries and three cannibals must all cross a river from the left bank to the right bank. The boat carries one or two people and cannot cross empty. On either bank, if any missionaries are present, cannibals must never outnumber them. Here is the current state and the legal moves available right now. Which move should be made next?
- 1 cannibalTake 1 cannibal from the left bank to the right bank. Afterwards: left bank 3 missionaries and 2 cannibals; right bank 0 missionaries and 1 cannibals; boat on the right bank.
- 2 cannibalsTake 2 cannibals from the left bank to the right bank. Afterwards: left bank 3 missionaries and 1 cannibals; right bank 0 missionaries and 2 cannibals; boat on the right bank.
- 1 missionary + 1 cannibalTake 1 missionary + 1 cannibal from the left bank to the right bank. Afterwards: left bank 2 missionaries and 2 cannibals; right bank 1 missionaries and 1 cannibals; boat on the right bank.
Jev decision
idleOne call per move. What it knows depends on the context level: from bank counts alone up to memory, lookahead and even distances to the goal.
The chess-engine split. Search guarantees an answer; Jev's scores decide which states to look at first. Here a simple rule orders them as well.
Expands every state level by level until it reaches the goal, then reads back the shortest path. Guaranteed optimal: 11 crossings.