Thomas Piacentini
← Workshop

05 / 15 · 60–90 min

Find a path.

Which cells should we explore to reach the goal at lowest cost?

Choose a laboratory
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.

S××333×333×××××××GS: start · G: goal · ×: obstacle · 3: terrain cost
Light trail: path. Tinted cells: expanded. Walls are marked ×; terrain 3 costs three units.

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.

Compare A and B →

Read values as a table
OrderColumnRow
1.000.000.00
2.001.000.00
3.002.000.00
4.002.001.00
5.002.002.00
6.002.003.00
7.003.003.00
8.004.003.00
9.004.004.00
10.005.004.00
11.006.004.00
12.007.004.00
13.007.005.00
14.007.006.00
15.007.007.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.

Open my notebook →

atomsh / lab