Transport 3 missionaries and 3 cannibals across a river using a boat that holds at most 2 people. Missionaries must never be outnumbered by cannibals on either bank. Explore the complete state space with 5 classical AI search algorithms.
Formally defining the state space, actions, validity constraints, and search parameters for this classic AI planning problem.
Each state is a tuple:
5 possible boat loads (missionaries, cannibals):
Missionaries must never be outnumbered:
Play the puzzle yourself! Select people on the boat's side, board them, then cross. Can you solve it in 11 moves?
Watch five classical AI search algorithms solve the puzzle with animated river crossing visualization.
Watch BFS, DFS, or A* explore the state space. Nodes are colored as they are discovered.
Side-by-side performance and property comparison of all five algorithms.
| Algorithm | Nodes | Path | Optimal? | Complete? | Time | Space | Heuristic |
|---|---|---|---|---|---|---|---|
| BFS | -- | -- | Yes | Yes | O(bd) | O(bd) | None |
| DFS | -- | -- | No | Yes* | O(bm) | O(bm) | None |
| A* | -- | -- | Yes | Yes | O(bd) | O(bd) | ceil((M+C)/2) |
| Greedy | -- | -- | No | Yes | O(bm) | O(bm) | ceil((M+C)/2) |
| IDDFS | -- | -- | Yes | Yes | O(bd) | O(bd) | None |
Detailed breakdown of each search algorithm with pseudocode and properties.
Explores all neighbors at current depth before moving deeper. Guarantees shortest path for unweighted graphs.
Explores as far as possible along each branch before backtracking. Memory efficient but may miss shortest path.
Uses f(n) = g(n) + h(n) to guide search. Optimal with admissible heuristic. Most efficient informed search.
Always expands node closest to goal. Fast but not optimal - ignores path cost entirely.
Combines BFS optimality with DFS memory. Repeats DFS with increasing depth limits.
Complete the puzzle to see how you stack up against BFS. Play the game first!