Ages 15–18 · Grades 9–12 · Computer Science
BehaviorForge
When an NPC finds its way across a level, it is not "thinking" — it is running a search algorithm. Here you pit breadth-first search, Dijkstra and A* against the same grid. All three reach the goal on an optimal path, but a good heuristic lets A* aim at the goal and finalize far fewer cells. Predict the winner, then run all three and read the numbers. This is classical AI — not machine learning.
Loading the search lab…
Where this idea comes from
Dijkstra and A*
In 1956 Edsger Dijkstra, a young programmer in Amsterdam, worked out how to find the shortest route between two cities in about twenty minutes, sitting on a café terrace with his fiancée, without pencil or paper; he published it in 1959. In 1968 Peter Hart, Nils Nilsson and Bertram Raphael at the Stanford Research Institute added a guess of the distance left, and called the result A*. They needed it for Shakey, a wheeled robot that had to plan its own way between rooms.
One thing to hold: A map of a few rooms with doorways, and a ruler to guess how far the goal still is.
Why it matters: A* finds the same cheapest route as Dijkstra, but its guess must never overestimate the distance left: then it can aim at the goal and look at far fewer places. Game characters and map apps still find their way with versions of these two searches.
What we don’t know: The café story comes from Dijkstra himself, told in an interview fifty years later; no notes from that day survive.
Dates:
- 1956 Dijkstra works out the shortest-route search on a café terrace.
- 1959 He publishes it in two pages.
- 1968 Hart, Nilsson and Raphael publish A*, built for the robot Shakey.
How are you feeling?
A case · you decide
Marisol's guard that got lost
Marisol, 16 — building a stealth game where the guard keeps walking into walls on the way to the player
Marisol's guard moves by picking whichever neighbouring tile is closest to the player in a straight line. In open rooms it looks smart. The moment a wall sits in between, the guard presses its face into the bricks and stays there.
Greedy straight-line chasing has no memory of where it has been and no idea a wall blocks the shortcut. It is fast, and it can get stuck.
A pathfinder looks ahead before moving. The question is which one: BFS treats every step the same, Dijkstra handles steps that cost different amounts (mud, stairs), and A* adds a guess of the distance left so it searches toward the goal.
Every floor tile costs the same to cross. Which fix gets the guard around the wall reliably?
Marisol adds mud tiles that cost three times as much to cross, and the map grows to 200 by 200. The guard now stutters. What should she use?
The guard now takes the long way round the mud and through the doorway, the way a real guard would. Marisol did not make it smarter by adding rules; she gave it a search that fits the map.
Who made this?
“In reality, every technology reflects decisions made by designers, companies, and communities, and carries the values and power of those choices.”
- Who benefits from this technology?
- Whose needs are ignored?
Brain break
What next? Pick a door
- More like this ChallengeForge Does this entry clear the rubric? VoxelEngine How is this voxel world built? ReviewForge Which test catches the bug?
- A bit harder LibraryForge What does this helper function return? PackForge Why does this content pack break? SpecForge Is your brief clear enough for the agent?
- Something different TranslateDojo What does this saying really mean? FeelDojo Does this answer you, or bait you? CauseForge Correlation, or cause?