Lesson plan

Agent Treasure Hunt

Students build a 10x10 enclosed arena, identify coordinates, and code the Agent using loops and conditionals to hunt for a hidden Redstone block.

Agent Treasure Hunt
Download lesson files
Ages
Ages 8-13
Essential question

Is it more efficient to search a fixed area randomly or by following an ordered sequence?

Overview

This lesson explores search algorithms and spatial reasoning by contrasting random searching with structured procedures. Students begin with an unplugged grid activity inspired by Battleship, measuring whether random guessing or systematic patterns locate a hidden target more quickly.

Inside Minecraft Education, students apply these concepts by building an enclosed 10x10 arena, concealing a Redstone block, and identifying coordinate boundaries. Using MakeCode, they program their Agent with While loops, random positions, and conditional statements to scour the perimeter and celebrate when the treasure is found.

Learning objectives

By the end of this lesson students will be able to:

  • Calculate the total number of perimeter wall blocks needed to enclose a 10x10 space.
  • Identify minimum and maximum X and Z coordinates within a flat boundary.
  • Explain why the vertical Y coordinate remains constant across a flat arena.
  • Program the Agent to patrol an arena using MakeCode While loops, conditionals, and random coordinates.
  • Code the Agent to identify a hidden Redstone block and perform a victory dance.

Blocks and items used in this lesson

Key vocabulary

Coordinates
A set of values (X, Y, Z) that define the exact position of a point in 3D space.
Perimeter
The continuous boundary or outer border enclosing a designated area.
While Loop
A programming command that repeats instructions continuously as long as a specified condition is true.
Conditional Statement
A coding structure (IF and Else) that runs specific actions only when certain conditions are met.

Before class

Lesson sequence

  1. Unplugged Search Experiment

    Introduce the lesson by referencing search strategies in games like Battleship. Pair students up with a 10x10 letter-and-number grid. One student selects a secret square while the other attempts to find it by guessing purely at random with a stopwatch running.

    Have pairs repeat this 10 times to calculate an average time. Repeat the process using a sequential pattern. Compare the results and discuss the advantages and disadvantages of random versus patterned searches, logging results in OneNote Class Notebook.

  2. Perimeter Building and Coordinates

    Students create a new grass world and build a perimeter wall encasing a 10x10 area of grass blocks. Challenge students to determine how many blocks are required before revealing that corners bring the total to 44 blocks rather than 40.

    Students then replace one grass block within the arena with a Redstone block. Have them record the X, Y, and Z coordinates of diagonally opposite corners, determining the minimum and maximum values of X and Z and explaining why Y does not change.

  3. Agent Random Navigation

    Students practice manually teleporting the Agent by editing X and Z values within the discovered boundary limits. Next, they open MakeCode to automate this behavior.

    Students construct a script that teleports the Agent to a random location inside the wall and drives it forward. When the Agent reaches the perimeter wall, the program teleports it to a new random location inside the boundary and continues the loop.

  4. Treasure Detection and Celebration

    Students modify their code using IF and Else conditions. As the Agent moves, it continuously checks the block directly beneath it.

    When the Agent detects the Redstone block, it must immediately stop moving forward and execute a small victory dance to signal that the treasure hunt is complete.

Assessment: success criteria

  • Student accurately explains why 44 blocks are required to enclose a 10x10 area.
  • Student correctly records the boundary coordinate ranges (maximum and minimum X and Z).
  • Agent script successfully uses a While loop to sustain continuous movement and boundary checking.
  • Agent successfully detects the Redstone block, stops forward motion, and performs a victory dance.

Differentiation

Support

Assist students by physically walking to diagonally opposite corners to record coordinate numbers together before writing code.

Stretch

Direct students to complete the extension exercises provided in the lesson handout.

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.

  1. 1How many perimeter blocks are required to completely enclose a 10x10 grass area?

  2. 2Why does the Y coordinate remain constant when moving inside this arena?

  3. 3Which MakeCode command allows the Agent to repeat search movements for an unknown number of times?

  4. 4What should the Agent do when it detects the Redstone block beneath it?

  5. 5What happens in the program when the Agent hits the perimeter wall?

Resources

Frequently Asked Questions

Why do students commonly guess that 40 blocks enclose a 10x10 space?

Students often multiply four sides by 10 without visualizing that the wall corners overlap, which adds four additional corner blocks to completely encase the area.

How can this lesson be adapted for a flipped classroom model?

Assign the illustrated handouts before the lesson so learners review coordinate concepts and coding steps ahead of time, leaving class time for a brief Q&A session and hands-on assistance.

Adapted from Agent Treasure Hunt by Nicos Paphitis on Minecraft Education, last updated Aug 26, 2019. This classroom version, the timings and the quiz were written by 9Minecraft Education.

You May Also Like

9Minecraft Education is an independent teaching resource and is not affiliated with Mojang or Microsoft. Lesson plans here are our own classroom-ready adaptations; each one links to the original resource and credits its author. © 2026 9minecraft.net