Family edition
Map Robot Lab: Directions or a Rule, Loops and Conditionals
In Map Robot Lab your child programs a delivery van in a small town, first with a list of directions, then with a rule that works for any trip.
What you need
- A computer or Chromebook with a current browser.
- The link: mytekdev.com/try/maprobotlab?lesson=directions-or-a-rule-loops-and-conditionals&ref=fam-maprobotlab-1. No account, no email and nothing to install.
Before you start: try it once yourself
Open mytekdev.com/try/maprobotlab?lesson=directions-or-a-rule-loops-and-conditionals&ref=fam-maprobotlab-1. A short guide opens over Level 1, Press play. 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.
- Level 1. The starter program is three blocks: drive east, drive east, drive south. Press play: the van reaches the Bakery in 3 blocks and 6 minutes.
- Level 2. Press Next. The same directions stop at the Bakery corner, and the card says the Pizza Place is 2 blocks north and 1 block east. East, north, north arrives in 6 minutes; north, east, north in 5; north, north, east in 4, the best possible.
- Level 3. Directions that reach the Pizza Place stop short on the Bakery and Zoo trips. The rule, repeat until arrived with an if for each way, delivers all three: the Pizza Place and the Bakery in 3 blocks and 6 minutes each, the Zoo in 8 blocks and 12 minutes.
- 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
Directions are a sequence: they work when you already know the way, from one start to one place. A rule that looks at where the goal is each time round a loop works for any trip in an open town. Children often expect a program to "know" where to go; the Level 3 run shows that the directions do exactly what they say, even when that is the wrong place.
The order of the checks matters for the route, not for arriving: with east and west first the van reaches the Zoo in 12 minutes, with north and south first in 8, both 8 blocks. Neither rule looks ahead, which is why both get stuck at the lake on Level 4. 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=directions-or-a-rule-loops-and-conditionals&ref=fam-maprobotlab-1 together and press play.
You'll know it worked when: The van drives east, east, south to the Bakery: 3 blocks in 6 minutes.
- Press Next: Level 2. In Blocks, change the directions so the van gets to the Pizza Place, then go back to Simulator and play.
If you get stuck: North is up. The Pizza Place is 2 blocks north and 1 block east of the Depot.
You'll know it worked when: East, north, north takes 6 minutes; north, north, east takes 4, because the green avenue is quicker.
- Press Next: Level 3 and play the same directions.
You'll know it worked when: They reach the Pizza Place but stop short on the Bakery and Zoo trips.
- Build the rule: repeat until arrived?, and inside it an if that drives east when the goal is east and the van can drive east, else west, else north, else south.
If you get stuck: The gear on the if block adds the else if parts.
You'll know it worked when: All three delivered: the Pizza Place and the Bakery in 3 blocks each, the Zoo in 8.
Talk about it
Ask these while you work together. A child who has understood it can answer them without help:
- Why did the Level 1 directions not reach the Pizza Place?
- Two of your directions were 3 blocks. Why did one take longer?
- Why can't one list of directions deliver to three places?
- What does the van check each time round the loop?
- Why is the if inside the repeat?
For younger and older kids
Younger: For a younger child, stop after Level 2, and race two orders of the same three moves.
Older: For an older child, swap the rule so north and south come first, and compare the minutes on all three trips.
Keep going
- Swap the order in the rule so north and south come before east and west. Run Level 3 again: which trips get faster, and why?
- Run the rule on Level 4. Where does it stop, and what would it need to know to get around the lake?
- Open the Python tab and find the line each block wrote.
Bring it into other subjects
- Math: on graph paper, mark the Depot at (0,2) and the Pizza Place at (1,4). How many blocks north, how many east? Write every shortest route.
- Social studies: write directions between two places in your town, then a rule that would work from anywhere.
- Writing: a recipe is a sequence. Find a step in one that is really a loop or an if.
- Careers: look up what a software engineer on a maps team does.
For your records
Ready to copy into an hour log, a portfolio or a transcript.
| Lesson | Map Robot Lab: Directions or a Rule, Loops and Conditionals |
|---|---|
| Subjects | Computer science |
| Time | 45 minutes |
| What we did | Programmed a simulated delivery van in Blocks: wrote directions, compared their minutes, and built a loop with conditionals that delivered to three places. |
| Skills practiced | Sequences; Loops and conditionals; Testing a program |
Map Robot Lab: Directions or a Rule, Loops and Conditionals
Activity sheet (optional)
Name: ______________________________ Date: ______________
Open the app: scan the QR code, or go to mytekdev.com/try/maprobotlab?lesson=directions-or-a-rule-loops-and-conditionals
Essential question: When does a list of directions work, and when do you need a rule?
Warm-up: Directions from your classroom to the cafeteria. Would they work from the gym? ________________________
- Vocabulary. Sequence, algorithm, loop, conditional, test case, minutes: write each in your own words.
- Level 1. East, east, south reached the ____ in ____ blocks and ____ minutes.
- Level 2. My directions: ________________ took ____ minutes. Another order: ________________ took ____ minutes. The best possible: ____ minutes.
- Level 3, three test cases. My directions: Pizza Place ____, Bakery ____, Zoo ____ (arrived or stopped). My rule: Pizza Place ____ blocks ____ min, Bakery ____ blocks ____ min, Zoo ____ blocks ____ min.
1. Why did one order of the same three moves take fewer minutes?
2. What does your rule check that your directions did not?
Quick check
Name: ______________________________
1. A program that drives east, east, south is: (A) a sequence (B) a loop (C) a conditional
2. Repeat until arrived runs its steps: (A) once (B) again and again until the van is there (C) only when the goal is east
3. A friend's directions reach the Bakery but not the Zoo. Use what you learned today to say what to change, and why.
Answers
| Question | Answer | Why |
|---|---|---|
| 1 | A | Three steps that run in order, once each. |
| 2 | B | A loop repeats its steps; until arrived is the condition that stops it. |
| 3 | Open answer | Write a rule instead: a loop that checks where the goal is each time and drives that way, so it works for any place, not only the one the directions were written for. |
If your state or umbrella school asks, this lesson covers CSTA 2017 1B-AP-08, CSTA 2017 1B-AP-10, CSTA 2017 2-AP-12, CSTA 2017 2-AP-17.