Lesson · with Voxel · Builder rank

Loop Awakening

Stop repeating yourself. Put the place-and-move blocks inside a repeat loop and build ten blocks with one command.

You need

  • Minecraft Education
  • A new flat creative world
  • The printable mission sheet (optional)

Steps

  1. Grab a loop

    From Loops drag 'repeat 4 times' into your build command and change 4 to 10.

  2. Move the blocks inside

    Put 'agent place forward' and 'agent move forward by 1' inside the loop. Order matters: place first, then move.

  3. Run and count

    Type build. Count the blocks. Ten blocks from one command is the whole point of a loop.

  4. Go square

    Wrap your repeat 10 loop in a 'repeat 4 times' loop and add 'agent turn left' after the inner loop. You just built the outline of a room.

Build task

Cave Cleanup Crisis

Program the Agent to build the four walls of a 10 by 10 room using nested loops.

Finish line: A closed 10 × 10 outline built by one command.

Check your understanding

1. Your loop places 10 blocks but they all land in the same spot. What is missing?
2. A repeat 4 loop holds a repeat 10 loop. How many times does the inner code run in total?
3. Why do programmers use loops?
Guest mode: your result is saved on this device only.