Family edition
Map Robot Lab: Stuck at the Lake, Why a Plan Looks Ahead
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
- A computer or Chromebook with a current browser.
- The link: mytekdev.com/try/maprobotlab?lesson=stuck-at-the-lake-why-a-plan-looks-ahead&ref=fam-maprobotlab-2. No account, no email and nothing to install.
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.
- 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.
- 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.
- 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.
- 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 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
- 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.
- 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.
- 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.
- 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:
- Where did heading for the goal stop, and why there?
- Which bubbles turn solid first, and why those?
- What does a dashed bubble mean, and what does a solid one mean?
- Why does the Library's bubble turn solid last?
- When would heading for the goal be good enough?
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
- Open Python and write the plan with a cost: def cost(road): return road.minutes(). Run Level 4: does the route change, and what happens to the minutes?
- Press Watch the ripple and count how many bubbles turn solid before the Library. Why so many?
- Draw a town where heading for the goal works and one where it fails, and test both on Level 9.
Bring it into other subjects
- Math: on graph paper, number every corner of a small grid by its fewest blocks from one corner. What pattern do the numbers make?
- Science: a real ripple on a pond spreads at the same speed in every direction. How is the planner's ripple the same, and how is it different?
- Geography: find a lake or river near your school, and a place across it. Is the straight line the way you would go?
- Careers: look up what a robotics engineer does to help a robot find its way.
For your records
Ready to copy into an hour log, a portfolio or a transcript.
| Lesson | Map Robot Lab: Stuck at the Lake, Why a Plan Looks Ahead |
|---|---|
| Subjects | Computer science |
| Time | 45 minutes |
| What we did | Programmed 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 practiced | Comparing 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? ________________________
- Vocabulary. Greedy algorithm, plan, ripple, bubble, cost, shortest path: write each in your own words.
- Stuck. Heading for the goal drove ____ blocks and stopped at (____ , ____). Why there? ________________________
- 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 ____.
- 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
| Question | Answer | Why |
|---|---|---|
| 1 | B | The rule only looks one block ahead, so it stops where it can't drive toward the goal. |
| 2 | A | The cheapest bubble is made solid next, so when the goal's turns solid no cheaper way can be left. |
| 3 | Open answer | It 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.