Thomas Piacentini
← Workshop

Guided lesson 05 / 10

Find a path.

Distinguish cost already incurred from estimated remaining cost, then compare A* and Dijkstra.

01 · Understand and consult

The idea before the settings.

The graph describes allowed moves and costs. Dijkstra explores by g, cost from the start. A* uses f = g + h, where h estimates remaining cost.

A consistent heuristic suits this search with closed nodes. On this four-neighbour grid with costs at least 1, Manhattan distance is consistent. A weight greater than 1 can sacrifice optimality.

A worked example.

From (0, 0) to (3, 4), Manhattan gives at least |3| + |4| = 7 moves. Walls can lengthen a route without making this lower bound too large.

Read these passages from the authors.

Introduction to A* · Red Blob Games · Reading links open a new tab.

  1. Representing the map ↗

    Distinguish the visible map from the graph used. Identify what an edge represents.

  2. Movement costs → The A* algorithm ↗

    Compare weighted exploration with adding a heuristic. Find g, h and their sum in the explanation.

If a resource fails to load, local explanations and trials remain available. You can continue and leave reading pending.

02 · Predict

Write before running.

At least 20 characters to document your hypothesis. A wrong prediction is useful: keep it and later explain what surprised you.

03 · Experiment and compare

Two trials, one question.

Each link loads prepared laboratory settings. Seeds match for randomized models. Record results and use “Keep this experiment” for each trial, then return here.

Trial A

Starting comparison.

Run Dijkstra, weight 0, on the initial map. Record cost and explored cells.

Open trial A →

No notebook record yet.

Trial B

Change an assumption.

Replay exactly the same map at weight 1. Compare cost and exploration, then open a passage in the editor to test the representation.

Open trial B →

No notebook record yet.

Opening a trial replaces this laboratory’s current settings. Saved experiments remain in the notebook. For a controlled comparison, record A and B as given before exploring freely.

04 · Solve

Calculate for yourself.

The laboratory’s numerical challenge checks a small calculation component. Use the hint after trying; this guide helps reconstruct the reasoning.

Solve the laboratory challenge →

Challenge pending.

Continue with the Python notebook ↗

05 · Explain and check

What my trials taught me.

At least 40 characters; cite measurements and one model limitation. Your text is kept in this browser and the notebook JSON export.

My success criteria · self-assessment

A graph path does not specify how a motor physically follows each edge.

atomsh / lab