Map Robot Lab: Directions or a Rule, Loops and Conditionals
Level 1 of Map Robot Lab runs a starter program, east, east, south, and the delivery van drives to the Bakery in 3 blocks and 6 minutes. Level 2 asks for the Pizza Place, and students write their own directions: east, north, north takes 6 minutes, and north, north, east only 4, because the green avenue is quicker. Level 3 asks for one program that delivers to three places, and directions cannot do it. Students build a rule instead, a loop that repeats until the van has arrived, with conditionals that drive whichever way the goal is, and it reaches all three.
At a glance
Essential question
When does a list of directions work, and when do you need a rule?
Objectives
Students will be able to:
- write a sequence of directions that drives the van to a place
- compare two sequences by the minutes they take
- explain why one list of directions cannot reach three different places
- build a loop with conditionals that drives toward the goal on any trip
- test a program on several trips and record the results
Vocabulary
Sequence, Algorithm, Loop, Conditional, Test case, Minutes
Standards
1B-AP-08, 1B-AP-10, 2-AP-12, 2-AP-17
Time and materials
45 minutes, grades 5-8.
- One computer or Chromebook per student
- A projector
- The worksheet and exit ticket, one copy each per student
- The rubric, one copy per student if you grade the work
Prep
Make copies of the worksheet and exit ticket. Before class, open mytekdev.com/try/maprobotlab?lesson=directions-or-a-rule-loops-and-conditionals&ref=tpt-maprobotlab-1 once on a student computer, which checks that your school's filter allows the app, and follow the short guide yourself: about ten minutes.
Assessment
- Formative: the questions under What to look for, asked while students work, and the exit ticket (answer key included).
- Summative: the worksheet, scored with the rubric.
Technology and privacy
Runs in any browser, Chromebooks included, with nothing to install. Students need no account and no email: the link works signed out, and nothing they do is stored on our server unless they choose to save.
mytekdev.com/try/maprobotlab?lesson=directions-or-a-rule-loops-and-conditionals&ref=tpt-maprobotlab-1mytekdev.com/tools/map-robot-lab/lessons/directions-or-a-rule-loops-and-conditionals/startEach student gets their own copy, and the same link reopens it next time. How to set up a classLesson sequence
| Minutes | Stage | What you do | What students do |
|---|---|---|---|
| 0 to 5 | Warm-up Hook | Show the title, essential question and Today I can slides (about 1 minute). Then the warm-up: directions from the classroom to the cafeteria, and from the gym. | Answer the warm-up on the worksheet. |
| 5 to 12 | Direct instruction (I do) Model it | Project Level 1. 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. Press play: the starter drives east, east, south to the Bakery, 3 blocks in 6 minutes. Open Blocks to show the three blocks. Then show the two Level 2 slides. | Watch, and fill in the vocabulary on the worksheet. |
| 12 to 22 | Guided practice (We do) Directions, then three trips | Students open the link or scan the QR code. A short guide walks them through Level 1, writing their own directions on Level 2, and running them on Level 3's three trips. 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. Watch for: Students who think north is down. North is up on the map; the Pizza Place is 2 blocks north and 1 block east of the Depot, and the card says so after a miss. | Follow the guide. Write each run's blocks and minutes on the worksheet. |
| 22 to 37 | Independent practice (You do) One rule for every trip | Show the slide of the finished blocks. Students build the rule on Level 3: repeat until arrived, and inside it an if with four parts, each pairing blocks to the goal with can drive. They run it and record all three trips. Students who finish run it on Level 4 (Levels, in the menu bar) and see what happens. Walk the room with the What to look for questions. If they ask: "Why does the if need to be inside the repeat? What would happen with only one if?" The loop Watch for: Students who leave out can drive. On Level 3 the rule still works, but the check is what stops the van trying to drive into the lake on Level 4. | Build the rule, run it, and fill in the three-trip table. |
| 37 to 45 | Closure Directions or a rule? And exit ticket | Show the closure slide and take answers. Name the ideas: a sequence for one trip, a loop with conditionals for any trip. Hand out the exit ticket. | Discuss, then answer the exit ticket. |
Before you teach: a ten-minute walkthrough
Open mytekdev.com/try/maprobotlab?lesson=directions-or-a-rule-loops-and-conditionals&ref=tpt-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.
Background for the teacher
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. Students 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).
What to look for
Ask these while students work. A student who has understood the lesson 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?
Cross-curricular extensions
- 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.
Vocabulary
| Sequence | Steps that run one after another, in order. East, east, south is a sequence. |
| Algorithm | A set of steps that solves a problem. Directions are one algorithm; a rule that works for any trip is a better one. |
| Loop | Steps that repeat. Repeat until arrived runs its steps again and again until the van is there. |
| Conditional | An if: steps that run only when something is true, like if the goal is east and the van can drive east. |
| Test case | One run used to check a program. Level 3 has three: the Pizza Place, the Bakery and the Zoo. |
| Minutes | How long a road takes. Each road shows its minutes, and the Trip log adds them up. |
Differentiation
English learners
- Keep the vocabulary slide up, and point at the van, the road numbers or the Trip log as you say each word: the picture carries the meaning.
- Give a sentence frame on a card: My directions work from ____ to ____. My rule works for ____ because it checks ____.
- Act it out: one student is the van and walks the classroom grid while a partner reads the directions.
Students with IEPs or 504 plans
- Pair students, one at the keyboard and one recording results.
- Give a printed picture of the finished blocks to copy, with the four ifs already ordered.
- Where the IEP allows a modified assignment, score the first two rubric rows only.
Students who need more support
- Do Levels 1 and 2 together on the projector before students start.
- Build the first if of the rule together, east only, and let students add west, north and south.
- The card says where the van stopped after every miss, and how far the place is.
Students ready for more
- 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.
Adapting for other grades
Younger students: In grade 4, stop after Level 2 and build the rule together on the projector, one if at a time. Score the first two rubric rows, total 8, and 6 meets the objectives.
Older students: In high school, write the rule in Python with robot.goal_east() and robot.goal_north(), and go straight on to Stuck at the lake, the next lesson in this series.
Map Robot Lab: Directions or a Rule, Loops and Conditionals
Student worksheet
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?
Map Robot Lab: Directions or a Rule, Loops and Conditionals
Exit ticket
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.
Answer key: exit ticket
| 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. |
Worksheet: what students should find
| Blank | What the app shows |
|---|---|
| Level 1 | The Bakery, 3 blocks, 6 minutes. |
| Level 2 | East, north, north: 6 minutes. North, east, north: 5. North, north, east: 4, the best possible. |
| Level 3 | Directions that reach the Pizza Place stop short on the Bakery and Zoo trips. The rule: Pizza Place 3 blocks 6 min, Bakery 3 blocks 6 min, Zoo 8 blocks 12 min. |
| Question 1 | The green avenue roads take 1 minute and the gray streets 2, so going north on the avenue first saves minutes. |
| Question 2 | Where the goal is, each time round the loop, and whether the van can drive that way. |
Rubric
Score each row from 1 to 4.
Name: ______________________________
| Criteria | 4 Exceeds | 3 Meets | 2 Approaching | 1 Beginning |
|---|---|---|---|---|
| Directions as a sequence | Writes directions that reach the Pizza Place in 4 minutes and explains why that order is fastest. | Writes directions that reach the Pizza Place. | Writes directions that do not reach it. | Does not change the directions. |
| Loops and conditionals | Builds the rule, delivers all three trips, and explains why the if is inside the loop. | Builds the rule and delivers all three trips. | Builds part of the rule, or it reaches one or two trips. | Does not build the rule. |
| Testing | Records every test case, compares the directions with the rule, and says what a fourth test should check. | Records the three trips for the directions and the rule. | Records some results. | Does not record results. |
Total: ____ / 12. A score of 9 or more meets the objectives.
Standards
The lesson is built for CSTA 1B-AP-10 and 2-AP-12: students write a sequence, then a loop with nested conditionals, each joining two tests with and, that drives the van on any trip. Comparing directions with the rule, and the orders of the moves by their minutes, is 1B-AP-08; running the rule on three trips and recording each is 2-AP-17.
| Framework | Code | Grades | Standard | How the lesson meets it |
|---|---|---|---|---|
| CSTA 2017 | 1B-AP-08 | 3-5 | Compare and refine multiple algorithms for the same task and determine which is the most appropriate. | Students compare directions with a rule for the same deliveries, and three orders of the same moves by their minutes, and decide which is the most appropriate. |
| CSTA 2017 | 1B-AP-10 | 3-5 | Create programs that include sequences, events, loops, and conditionals. | Students write a sequence of drive blocks, then a repeat until arrived loop with conditionals, started by the when started event. |
| CSTA 2017 | 2-AP-12 | 6-8 | Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals. | Students design the rule as a loop around an if with four parts, each a compound condition (blocks to the goal and can drive), and refine it run by run. |
| CSTA 2017 | 2-AP-17 | 6-8 | Systematically test and refine programs using a range of test cases. | Students test the same program on Level 3's three trips and record each result. |
Checked December 2026 against: CSTA K-12 Computer Science Standards, Revised 2017.
Optional: save student work in a free class
The whole lesson runs at the link on the worksheet, with no accounts and no sign-up.
To keep students' work, and see it all in one place, make a free class. It takes about ten minutes, once, and covers every lesson in this series: mytekdev.com/tools/class-setup
Students in a class open mytekdev.com/tools/map-robot-lab/lessons/directions-or-a-rule-loops-and-conditionals/start instead of the worksheet link. Each one gets their own copy of the starter, and the same link reopens it next time.