Introduction
15 minLast lesson the Agent walked. It went where you told it, traced a letter M across the ground — and left nothing behind. The moment the program finished, there was no sign it had ever been there.
Today it builds. By the end of this lesson the Agent will lay a line of stone, write your letters into the ground for good, and put up a tower taller than you are.
The Agent has its own inventory
The Agent carries its own blocks, in its own bag, separate from yours. That bag has 27 slots, and you fill them in code — not by hand, and not from your own inventory.
That is what the agent set item block does. You tell it three things, in this order:
| You choose | Means | Example |
|---|---|---|
| the block | what the Agent is carrying | stone |
| how many | how many of them | 64 |
| which slot | where in the bag it goes | slot 1 |
🔥 An Agent with an empty bag places nothing, and says nothing. It runs your whole program, places not one block, and gives you no error at all. When a build comes out invisible, check this first.
Placing is relative, just like moving
agent place on down puts a block under the Agent's feet. agent place on forward puts one in front of it. The direction word works exactly the way it did last lesson: it means from the Agent, not from you and not from north.
That gives you the pattern this whole lesson is built on:
place, move, place, move — the Agent lays a block, steps on, and lays another.
Placing does not move the Agent, and moving does not place anything. They are two separate blocks, and you will use them in pairs all lesson.
Destroy is the undo button
agent destroy forward breaks the block in front of the Agent. You will want it: the first build that comes out wrong is much easier to clear with a program than to chip away by hand.
What you will be able to do
- Fill the Agent's inventory from code and choose which slot it uses.
- Place blocks in any of the six directions, and destroy them.
- Build a line, a square and a tower without touching a single block yourself.
- Copy blocks quickly in MakeCode, instead of dragging every one out of the drawer.
Warm-up — back to the thousand-block wall
In Lesson 1 you worked out that placing a thousand blocks by hand is nearly seventeen minutes of clicking. Today you finally have the robot that can do it for you.
So count as you go. Every block the Agent lays needs a place and a move — two blocks of program for one block of world. A wall of a thousand would be two thousand blocks of program, and you would be dragging them out until next year.
That is not a reason to give up. It is the exact problem Lesson 3 solves, and you will appreciate the fix far more having felt the problem.
Basic
20 minFollow along on your own computer. Everyone should finish this part with the same working program.
Step 1 — The same flat world
Open your agent-school world from Lesson 1, or make a new one the same way: World Type Flat, Creative, Peaceful, Activate Cheats on, Show Coordinates on.
Flat mattered last lesson because the Agent stops dead at a slope. It matters more today: a shape built across a hillside cannot be seen, and half of it ends up buried.
We will build in stone on a grass flat world, so every block the Agent lays stands out against the ground.
Step 2 — Fill the Agent's bag
Press C, open your project, and start a new chat command called line.
Read it out loud: come to me, and put 64 stone into slot 1.
The Agent uses slot 1 unless you tell it otherwise, so filling slot 1 is all today needs.
Step 3 — Place one block
Add one more block and run it.
Press C, press T, type line, press Enter. The Agent appears beside you and a single stone block appears under its feet, replacing the grass.
One block. Now we want a row of them.
Step 4 — Place, move, place, move
The Agent has to step off a block before it can lay the next one. So the pair is always place then move:
Challenge 1
15 minBuild MC — and make it stay.
Last lesson the Agent walked the letters M and C and they vanished the moment it finished. Today you build them into the ground, so they are still there tomorrow.
- Fly to a clear, flat piece of ground and land.
- Press
Cand start a new chat command calledbuild-mc. - Begin it by bringing the Agent to you and putting 64 stone into slot 1.
- Build a letter M, 4 blocks tall and 3 blocks wide, flat on the ground so you can read it from above. Remember the pattern: place, move, place, move.
- Leave a gap of 2 blocks, then build a letter C beside it, also 4 tall and 3 wide. A C is open on one side — the bottom, the left, and the top.
- Go back to the world, press
T, typebuild-mcand pressEnter. Then fly straight up and look down at your work.
Use right-click → Duplicate for every place-and-move pair. Dragging them out one at a time will take you the whole lesson.
It works if: you can fly above the ground, look down, and read the letters MC in stone — and they are still there after the program has finished and the Agent has gone.
Challenge 2
20 minBuild a square pattern.
In Lesson 1 the Agent walked a square. Now it leaves one behind.
- Fly to a clear, flat piece of ground and land.
- Press
Cand start a new chat command calledsquare. - Bring the Agent to you and fill slot 1 with stone.
- Build the outline of a square with sides of 4 blocks — the four edges only, not filled in.
- The Agent must finish on the block it started from, facing the way it started.
- Go back to the world, type
square, then fly up and look down at it.
You will need agent turn at the corners. Each side is the same run of blocks as the one before it, so build one side, then duplicate it.
It works if: looking down from above you see a closed square outline of stone with a hollow middle, and the Agent is standing back where it began.
Fullscreen it while you build — you can pause and scrub with the player's own controls.
Challenge 3
25 minBuild a tower.
Everything so far has been flat. A tower goes the one way the Agent has not built yet: up.
- Fly to a clear, flat piece of ground and land.
- Press
Cand start a new chat command calledtower. - Bring the Agent to you and fill slot 1 with stone.
- Build a tower 10 blocks tall on the spot where the Agent starts. Work out for yourself which two blocks make the pair this time — the Agent has to be standing above a block before it can lay the next one under itself.
- When the tower is finished, bring the Agent back down to the ground.
- Go back to the world, type
tower, and stand back to watch it go up.
It works if: a stone tower 10 blocks tall is standing where the Agent started, it is one block wide all the way up with no gaps, and the Agent is back on the ground beside you at the end.
Extra challenge
spare timeThe staircase.
A tower you cannot climb is not much use. Build one you can walk up.
- Fly to a clear, flat piece of ground and land.
- Write one chat command called
stairsthat builds a staircase of 5 steps, each step one block higher and one block further on than the last. - Do not fly and do not jump — walk up it on foot to test it.
Each step is the same short run of blocks as the one before, so build one step and duplicate it four times.
It works if: you can walk from the ground to the top of the staircase on foot, without jumping and without flying, and each step is exactly one block higher than the one before it.
Count the cost
When it works, count the blocks in your program and write the number in your book. Then work out what a 50-step staircase would cost you, at the same number of blocks per step.
Write that number down too, and look at it. In Lesson 3 you will build the same staircase with a repeat block, and the program will be roughly four blocks long whatever the number of steps. That comparison is the whole reason the next lesson exists.
Fullscreen it while you build — you can pause and scrub with the player's own controls.