For a teacher with a class? The classroom edition has the full plan, slides and standards.

Homeschooling PDF

Family edition

Map Robot Lab: Stuck at the Lake, Why a Plan Looks Ahead

Ages 10-14 ยท about 45 minutes, in one sitting

In Map Robot Lab your child watches a delivery van get stuck at a lake, then steps through the route planner a map app uses and programs the van to plan ahead.

What you need

Before you start: try it once yourself

Open mytekdev.com/try/maprobotlab?lesson=stuck-at-the-lake-why-a-plan-looks-ahead&ref=fam-maprobotlab-2. A short guide opens over Level 4, The lake. The town fills the view from above: a lake in the middle, a green avenue around the edge where each road takes 1 minute, gray streets that take 2, and Main Street, stuck in traffic, at 5. Each road shows its minutes. The card at the right says the level's goal and, after each run, what happened, with the run's own numbers. The Trip log counts blocks, minutes, school roads and plans made, and the charts under the map keep every route tried on the trip.

  1. Stuck. The starter blocks head for the goal: repeat until arrived, drive east if the Library is east and the van can, else west, north or south. Press play: 2 blocks and 4 minutes, then the van stops at (2,2), with the lake to the east.
  2. The ripple. Press Watch the ripple, then Step. The Depot is 0; the three corners one block away get 1 and turn solid first; then every corner at 2, and so on. All 39 land corners turn solid, the Library last, at 11. Press play to watch the rest.
  3. The plan. In Blocks, replace the loop with plan a route to the goal and follow the route, from Plan. The van arrives in 11 blocks and 33 minutes: the fewest blocks, because every road costs 1.
  4. Speed. Slower, Real time and Speed up, under the map, change only how fast the van moves on the screen; the minutes do not change. Step moves the van one block, or the ripple one corner. The round play button runs the program from the start. The town has no randomness: the same program drives the same way on every run and every computer.
The minutes are not the point of this lesson: the plan counts blocks, so it drives past slow roads. Children who notice the 33 minutes have found the next lesson, What does best mean?

The ideas, in plain words

Heading for the goal is a greedy algorithm: it takes the move that looks best right now. In an open town it works, and quickly. When something is in the way it can walk into a dead end, because it never looks further than one block.

The planner is a shortest-path search. Each corner gets a bubble with the cost so far; the cheapest bubble is made solid, and its neighbors get bubbles, or smaller numbers if this way in is cheaper. Once a bubble is solid, no cheaper way can turn up, so when the goal's bubble turns solid the route is traced back to the van. With every road costing 1, the numbers are blocks. The ripple is a simple version of what computer scientists call Dijkstra's algorithm, worked out in 1956 and published in 1959. Real map apps use the same idea with extra tricks that make it fast enough for millions of roads, and they get news while you drive, such as traffic and closed roads other drivers report.

Software engineers who build maps and delivery apps write route planners like this one, and logistics planners decide what a route should cost: time, fuel, tolls or safety. Software developers earned a median of $133,080 in May 2024 (U.S. Bureau of Labor Statistics).

Do it together

  1. Open mytekdev.com/try/maprobotlab?lesson=stuck-at-the-lake-why-a-plan-looks-ahead&ref=fam-maprobotlab-2 together. Ask where the van will stop, then press play.

    You'll know it worked when: It drives 2 blocks east and stops at the lake: the Library is east, and the van can't drive east.

  2. Press Watch the ripple, then press Step a few times.

    You'll know it worked when: Bubbles spread out from the Depot. The cheapest one turns solid each time, and its neighbors get numbers.

  3. In Blocks, take off the repeat loop and put plan a route to the goal and follow the route under when started. Back in Simulator, press play.

    If you get stuck: The plan blocks are in the Plan drawer, on the left of Blocks.

    You'll know it worked when: The van arrives at the Library: 11 blocks, 33 minutes.

  4. Press Watch the ripple again and press play to watch it all. Which bubble turns solid last?

    You'll know it worked when: The Library, at 11: the ripple looks at all 39 land corners before the route is drawn.

Talk about it

Ask these while you work together. A child who has understood it can answer them without help:

The third question is the one that matters. A child who says "dashed is the best so far, solid is sure" understands why the planner can trust the route. A child who says "solid means visited" has half of it.

For younger and older kids

Younger: For a younger child, press Step together and say each bubble's number aloud before it appears.

Older: For an older child, count how many bubbles turn solid before the Library's does, and talk about why the planner looks at so much of the town.

Keep going

Bring it into other subjects

For your records

Ready to copy into an hour log, a portfolio or a transcript.

LessonMap Robot Lab: Stuck at the Lake, Why a Plan Looks Ahead
SubjectsComputer science
Time45 minutes
What we didProgrammed a simulated delivery van: saw a heading-for-the-goal rule get stuck at a lake, stepped through a shortest-path planner, and used it to plan a route.
Skills practicedComparing algorithms; Shortest paths; Planning ahead

Map Robot Lab: Stuck at the Lake, Why a Plan Looks Ahead

Activity sheet (optional)

Name: ______________________________ Date: ______________

Open the app: scan the QR code, or go to mytekdev.com/try/maprobotlab?lesson=stuck-at-the-lake-why-a-plan-looks-ahead

Essential question: Why does a program that always heads for the goal get stuck, and how does a plan fix it?

Warm-up: Walking straight toward the far side of a pond: what happens at the water's edge? ________________________

  1. Vocabulary. Greedy algorithm, plan, ripple, bubble, cost, shortest path: write each in your own words.
  2. Stuck. Heading for the goal drove ____ blocks and stopped at (____ , ____). Why there? ________________________
  3. Number the ripple. Every road costs 1, and the Depot is 0. Write the bubble numbers on the corners near the Depot, then check them with Watch the ripple and Step. The first corners to turn solid: ____ corners at ____.
  4. The plan. Plan, then follow: ____ blocks, ____ minutes. The last bubble to turn solid: the ____, at ____.

1. Why does the planner make the cheapest bubble solid first?

2. When is heading for the goal good enough, and when do you need a plan?

Quick check

Name: ______________________________

1. A van always drives toward the goal. A lake is in the way. The van: (A) goes around (B) gets stuck at the edge (C) plans a new route

2. In the ripple, the next bubble to turn solid is: (A) the cheapest one (B) the closest to the goal (C) the one reached first

3. A friend says planning is a waste of time because heading for the goal reached the Bakery. Use what you learned today to answer.

Answers

QuestionAnswerWhy
1BThe rule only looks one block ahead, so it stops where it can't drive toward the goal.
2AThe cheapest bubble is made solid next, so when the goal's turns solid no cheaper way can be left.
3Open answerIt works in an open town, but when something is in the way it can get stuck, as at the lake. A plan looks at the whole town first, so it finds a way whenever there is one.

If your state or umbrella school asks, this lesson covers CSTA 2017 1B-AP-08, CSTA 2017 2-AP-17.