
- Type
- Lesson plan
- Subject
- Computer Science & Coding
- Grade
- Middle school (Grades 6-8)High school (Grades 9-12)Adults & educators (Higher education and teacher learning)
- Ages
- Ages 11+
- Duration
- 1 hour
- Level
- Intermediate
How can while loops and ordered sequences help an autonomous Agent navigate and construct in hazardous, changing environments?
Overview
In this lesson, students explore automated emergency relief by programming the Agent to perform construction tasks in areas too hazardous for human workers. Learners discover how while loops and sequences allow autonomous assistants to navigate dynamic environments, repeating vital construction actions until safety criteria or spatial boundaries are reached.
Using simulated disaster zones in Minecraft, students code the Agent to follow pre-laid Redstone dust guidelines. By directing the Agent to assemble flood barriers, build concrete firebreaks across uneven terrain, and lay reconstructed home foundations, learners see how conditional code solves real-world logistics challenges.
Learning objectives
By the end of this lesson students will be able to:
- Utilize while loops to repeat code blocks based on active conditions.
- Recognize the importance of sequence order in program execution.
- Apply conditional loops to follow Redstone dust guides over varied terrain.
- Distinguish when to choose a while loop over a for loop for autonomous navigation.
Blocks and items used in this lesson
Key vocabulary
- While Loop
- A programming structure that continues to repeat an action as long as its specified condition remains true.
- Sequence
- The exact order in which a computer executes a series of commands.
- Condition
- A logical test evaluated by code to decide whether to execute an action.
- Firebreak
- An obstacle or cleared strip of land designed to halt the advance of an active fire.
Before class
Lesson sequence
Suggested timing: about 60 minutes in total.
- Concept Introduction10 min
Introduce the emergency response scenario using the classroom presentation. Explain how while loops operate based on conditions and demonstrate why precise sequence order matters when the Agent executes multi-step commands.
- Activity 1: Water Barrier15 min
Direct students to help emergency personnel by programming the Agent to lay down a protective water barrier along marked Redstone guidelines to halt floodwaters.
- Activity 2: Firebreak20 min
Task students with building a one-block-high concrete firebreak across uneven terrain. Learners must implement two while loops—one following the Redstone dust path and another checking ground elevation—combining a flat placement sequence with an elevation-climbing sequence.
- Activity 3: Home Reconstruction10 min
Have students code the Agent to rebuild house foundations following a hurricane by reading and tracing the foundation layout marked out in Redstone dust.
- Review and Formative Check5 min
Gather the class to review key concepts using the formative assessment questions, focusing on loop conditions, sequence definitions, and when to favor while loops over for loops.
Assessment: success criteria
- The student creates a functioning while loop that repeats commands only while its condition remains true.
- The Agent successfully navigates uneven ground by triggering the correct sequence when elevation changes.
- The student can explain that while loops are chosen over for loops when the total number of movement steps is unknown.
Differentiation
Walk through the two separate firebreak movement sequences on the board before students attempt to nest their elevation-checking while loop.
Ask advanced students to refine their firebreak code so it minimizes unnecessary checks while handling varying step heights.
Knowledge check
5 questions to check understanding after the lesson. Tap an answer to see if it is right; the score appears at the end.
1When does a while loop repeat its code?
Answer: A. A while loop runs and repeats instructions only as long as its specified condition is met.
2What is a sequence in computer science?
Answer: C. A sequence represents the specific order in which instructions are executed by the computer.
3What happens if the condition in a while loop is false?
Answer: B. If a while loop's condition evaluates to false, the code inside the loop does not run.
4When would you choose a while loop instead of a for loop to move the Agent forward?
Answer: D. A while loop is ideal when the required number of steps is unknown beforehand, allowing the Agent to move until a condition changes.
5In Activity 2, why does the Agent need two different sequences to build the firebreak?
Answer: B. The Agent uses one sequence to place and move on flat land, and a second sequence to climb and place blocks when the elevation shifts.
Resources
- Lesson package (.zip)Everything the author attached to this lesson in one download.
- Python 101-Lesson 7: Emergency ResponseEDU Guide
- Python 101-Lesson 7: Emergency ResponsePresentation
- Programming with PythonCurriculum Overview
- Lesson worldOpens the world page in Minecraft Education (sign-in with a school account may be needed).
Part of the Python 101 curriculum
This is lesson 7 of 10 in Python 101.
- Python 101 with MakeCode - Lesson 1
- Python 101 with MakeCode - Lesson 2
- Python 101 with MakeCode- Lesson 3
- Python 101 with MakeCode - Lesson 4
- Python 101 with MakeCode - Lesson 5
- Python 101 with MakeCode - Lesson 6
- Python 101 with MakeCode - Lesson 7
- Python 101 with MakeCode - Lesson 8
- Python 101 with MakeCode - Lesson 9
- Python 101 with MakeCode - Lesson 10
Frequently Asked Questions
How does the Agent know where to build the emergency structures?
Emergency workers have laid down visual path guidelines using Redstone dust, which students program the Agent to follow during each activity.
What specific actions make up the two sequences in the firebreak activity?
The first sequence directs the Agent to place a block to its left and move forward. The second sequence directs the Agent to place a block to its left, move up, place another block, and then step forward to accommodate elevation shifts.
Adapted from Python 101 with MakeCode - Lesson 7 by Minecraft Education on Minecraft Education, last updated Jun 14, 2023. This classroom version, the timings and the quiz were written by 9Minecraft Education.























