05 / 15 · 60–90 min
Find a path.
Which cells should we explore to reach the goal at lowest cost?
Check my intuition
01 · Predict
Before changing the settings.
An obstacle-free grid allows four directions, with cost 1 per move. From (1, 1) to (4, 5), what is the Manhattan distance?
A hint
Add the horizontal and vertical differences.
02 · Experiment and compare
Put the model to the test.
Use the editor cells to open a passage, add costly terrain or enclose the goal. Compare weight 0 (Dijkstra), 1 (A*) and 2. Step through explored cells with the slider.
Path found. 14 moves, cost 14. Dijkstra reference: 14.
- A* cost
- 14.00
- A* expansions
- 15.00
- Dijkstra expansions
- 46.00
Edit the map cells
Choose the edit type in settings. Arrows move focus; Enter or Space edits a cell.
Read values as a table
| Order | Column | Row |
|---|---|---|
| 1.00 | 0.00 | 0.00 |
| 2.00 | 1.00 | 0.00 |
| 3.00 | 2.00 | 0.00 |
| 4.00 | 2.00 | 1.00 |
| 5.00 | 2.00 | 2.00 |
| 6.00 | 2.00 | 3.00 |
| 7.00 | 3.00 | 3.00 |
| 8.00 | 4.00 | 3.00 |
| 9.00 | 4.00 | 4.00 |
| 10.00 | 5.00 | 4.00 |
| 11.00 | 6.00 | 4.00 |
| 12.00 | 7.00 | 4.00 |
| 13.00 | 7.00 | 5.00 |
| 14.00 | 7.00 | 6.00 |
| 15.00 | 7.00 | 7.00 |
Understand the calculations
03 · Connect the diagram to calculations
The numbers behind motion.
Cost g adds entered terrain costs, excluding the starting cell. h is Manhattan distance, a lower bound because every move costs at least 1. Weight 0 gives Dijkstra. Weight 1 with this consistent heuristic finds an optimal path. Above 1, search may favour speed and lose that guarantee. The map is known and static during search.
f(n) = g(n) + w h(n)
h = |x − x_goal| + |y − y_goal|
g(next) = g(current) + terrain(next)A few lines to reconstruct
priority = cost_so_far + weight * manhattan(cell, goal)The notebook provides one function per laboratory, hand-calculated examples and tests. Exercises isolate components; these pages run the complete simulations.
Keep an observation
04 · Record
What changed?
Compare two settings. Record the effect, your explanation and a case where the model might fail. Saving keeps the current settings and seed, not a certification of competence.
atomsh / lab