Teaching at home? The family edition is the same lesson, written for a parent and one to three kids.

Slides for the board (PowerPoint, 12 slides) Lesson PDF Google Slides: upload the PowerPoint file to Google Drive and open it with Google Slides.

Map Robot Lab: Directions or a Rule, Loops and Conditionals

Grades 5-8 · 45 minutes · Computer science

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.

Lesson sequence

MinutesStageWhat you doWhat students do
0 to 5Warm-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 12Direct 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 22Guided 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 37Independent 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 45Closure
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.

  1. 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.
  2. 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.
  3. 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.
  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 rule in Blocks reads blocks to the goal east greater than 0 and can drive east, then drive east, with the same for west, north and south. The gear on the if block adds the else if parts. On Level 4 the same rule stops at the lake: that is the next lesson.

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:

The fourth question is the one that matters. A student who says "it checks where the goal is, every time" has the idea of a rule. A student who says "it knows the way" has not yet separated the program from the map.

Cross-curricular extensions

Vocabulary

SequenceSteps that run one after another, in order. East, east, south is a sequence.
AlgorithmA set of steps that solves a problem. Directions are one algorithm; a rule that works for any trip is a better one.
LoopSteps that repeat. Repeat until arrived runs its steps again and again until the van is there.
ConditionalAn if: steps that run only when something is true, like if the goal is east and the van can drive east.
Test caseOne run used to check a program. Level 3 has three: the Pizza Place, the Bakery and the Zoo.
MinutesHow 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? ________________________

  1. Vocabulary. Sequence, algorithm, loop, conditional, test case, minutes: write each in your own words.
  2. Level 1. East, east, south reached the ____ in ____ blocks and ____ minutes.
  3. Level 2. My directions: ________________ took ____ minutes. Another order: ________________ took ____ minutes. The best possible: ____ minutes.
  4. 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

QuestionAnswerWhy
1AThree steps that run in order, once each.
2BA loop repeats its steps; until arrived is the condition that stops it.
3Open answerWrite 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

BlankWhat the app shows
Level 1The Bakery, 3 blocks, 6 minutes.
Level 2East, north, north: 6 minutes. North, east, north: 5. North, north, east: 4, the best possible.
Level 3Directions 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 1The green avenue roads take 1 minute and the gray streets 2, so going north on the avenue first saves minutes.
Question 2Where the goal is, each time round the loop, and whether the van can drive that way.
The town has no randomness: these numbers are the same on every run and every computer. A rule that checks north and south first reaches the three places in 4, 5 and 8 minutes: also right.

Rubric

Score each row from 1 to 4.

Name: ______________________________

Criteria4 Exceeds3 Meets2 Approaching1 Beginning
Directions as a sequenceWrites 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 conditionalsBuilds 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.
TestingRecords 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.

FrameworkCodeGradesStandardHow the lesson meets it
CSTA 20171B-AP-083-5Compare 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 20171B-AP-103-5Create 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 20172-AP-126-8Design 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 20172-AP-176-8Systematically 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.