Imagine standing on a riverbank with three things that do not get along. You have a small boat with room for one passenger. Can you get everyone safely across?
#What you do
You need to ferry a wolf, a goat, and a cabbage across a river. Your boat is tiny, so you can take only one of them each trip. Here is the tricky part. Leave the wolf alone with the goat, and the wolf eats the goat. Leave the goat alone with the cabbage, and the goat eats the cabbage. You must plan every trip so a dangerous pair is never left alone.
The clever move is that you are allowed to bring something back. That feels strange, because going backward seems like a waste. But sometimes a step back is the only way forward. You might carry the goat over, row back empty, take the wolf across, then bring the goat home again so it is not left with the wolf.
#What is really happening
Every moment in this puzzle is a little picture of where everyone stands. Who is on the left bank, who is on the right, and where the boat sits. Grown-ups call each picture a state, and a move carries you from one state to another.
A computer solves puzzles like this by searching. It quietly tries states, one after another, asking a simple question each time. Did that break a rule, and does this get me closer to the goal? It backs out of dead ends and keeps looking until it finds a chain of safe moves. That patient trying, checking, and backing up is what people mean by search.
#Where it shows up
This is not only a game about farm animals. A map app searches through roads to find your route. A robot searches through moves to tidy a room. The river is a friendly way to meet a big idea.
Ready to try it yourself? play it and see how few trips you need.
#The short version
- You move a wolf, a goat, and a cabbage across a river one at a time.
- Never leave the wolf with the goat, or the goat with the cabbage.
- Sometimes you carry something back, because forward is not always fastest.
- Computers solve puzzles like this by searching through possible states.