Introduction
15 minEvery instruction you have written so far means something only to the Agent. Forward is forward for the Agent. Up is up from wherever it happens to be standing.
That is fine for driving a robot about. It is useless for saying where something is.
Every block in the world has an address
Three numbers name any block in Minecraft, and you have had them on your screen since Lesson 1:
| Number | Runs | Gets bigger when you go |
|---|---|---|
| X | east and west | east |
| Y | up and down | up |
| Z | north and south | south |
X 100, Y 4, Z 200 is one exact block, and it is the same block tomorrow, for everybody, whatever the Agent is doing. That is what absolute means, and it is the opposite of everything you have written until now.
Two corners describe a box
Here is the idea the whole lesson turns on.
Pick a block. Pick another one some distance away, diagonally. Those two blocks are opposite corners, and between them sits a box — a region of the world with a definite size.
You do not need to describe the inside of that box. Two corners is enough. Everything in between is implied.
And fill builds the whole box at once
The Blocks drawer has a block that takes exactly that: a material, and two corners.
fill
stonefrom100 3 200to109 3 209
One block of program. A hundred blocks of floor. Instantly — no walking, no placing, no Agent, and no inventory.
The ceiling is gone
Remember Lesson 4. You worked out that 49 blocks fit in a slot, 64 was the whole slot, and 100 was simply impossible, however cleverly you nested your loops. I told you then that the answer was coming.
This is it. That impossible 10 by 10 floor is one fill block, and so is a 40 by 40 one. The Agent carries blocks; fill does not carry anything. It simply changes the world.
Warm-up — finding a seat
In a theatre, row 12, seat 4 finds exactly one seat out of hundreds, and no one has to walk you there.
Minecraft needs a third number only because it has height as well as length and width. Two numbers find a seat on the floor; three find a seat in a tower block.
What you will be able to do
- Read your own position and say which number changes when you move which way.
- Name any block in the world by its three numbers.
- Fill a floor, a wall and a solid cube with one block of program each.
- Hollow out a building, and carve doorways by filling with air.
Basic
20 minFollow along on your own computer. Everyone should finish this part with the same working build.
Step 1 — Find out where you are
Go into your flat world and look at the three numbers at the top left.
- Walk in a straight line and watch which number changes. Turn ninety degrees and walk again — now a different one changes.
- Fly straight up. Only Y moves.
- Write down which direction makes X get bigger, and which makes Z get bigger.
Do this properly. Everything below depends on knowing which number is which, and two minutes of walking now saves an hour of confusion later.
Step 2 — Stand still and write your numbers down
Land somewhere clear and flat. Note all three numbers — call them your home numbers. The examples below use 100 4 200; use your own everywhere you see those.
Your feet are at Y 4, so the ground you are standing on is the block below you, at Y 3. That one-block difference catches everybody once.
Step 3 — Your first fill: a floor
Press C, open your project, and make a new chat command called floor.
From the Blocks drawer, drag out a fill block.
Look carefully at the two corners. Y is 3 in both — the floor is one block thick. X runs 100 to 109, which is ten blocks. Z runs 200 to 209, ten more.
Go into the world and type floor.
A hundred blocks of stone appear at once. That is the build Lesson 4 proved you could not make with the Agent. It took one block of program and no time at all.
Step 4 — Make it a box
Change the second corner's Y from 3 to 8 and run it again.
Now the fill runs from Y 3 up to Y 8 — six layers of a hundred. Try counting that on your fingers, then remember that the Agent's whole bag holds sixty-four.
Challenge 1
15 minA floor and a wall.
Fills of your own, to a given size.
- Land somewhere clear and flat and write down your three numbers.
- Press
Cand make a new chat command calledplatform. - With one fill block, build a stone floor 20 blocks by 20, one block thick, level with the ground you are standing on.
- With a second fill block in the same command, build a glass wall along one edge of that floor — 20 blocks long, 4 blocks high and one block thick.
- Go into the world and type
platform, then walk out onto it.
Work the corners out on paper before you type them. For a 20-block run, the two numbers differ by 19, not 20 — count on your fingers from 1 to 4 and you will see why.
It works if: you can walk the full length of a square stone platform, there is a glass wall standing along exactly one edge of it, and the wall is four blocks high everywhere.
Challenge 2
20 minA room you can walk into.
Build a hollow room and then cut a door in it.
- Press
Cand make a new chat command calledhut. - With one fill block, build a hollow stone room 12 by 12 and 5 blocks high, sitting on the ground.
- With a second fill block in the same command, cut a doorway through one wall — 2 blocks high and 1 block wide — by filling with air.
- Run it, then walk in through your doorway without flying or breaking anything.
The doorway is the fiddly part. Its two corners are both in the same wall, so two of the three numbers will be the same in both corners.
It works if: you can walk in at ground level, stand up inside without your head in the ceiling, and the room is closed everywhere else.
Challenge 3
25 minA building on purpose.
One fill makes a box. Several fills make architecture.
- Press
Cand make a new chat command calledtower. - Design a building at least three storeys tall and build it with fill blocks only — no Agent anywhere in the program.
- It must have all of these, and each one is at least one fill:
- an outer shell you can walk into,
- a floor dividing at least two of the storeys,
- windows cut with air,
- and a material that changes somewhere, so it is not one colour from top to bottom.
- Work out every corner before you start. Sketching it on squared paper is faster than guessing and re-running.
- Run it, then walk in and go up through it.
It works if: you can get inside at ground level, there is a floor above your head that you could stand on, daylight comes through a window you cut, and at least two different materials are visible from outside.
Extra challenge
spare timeA room to order, built by fill.
In Lesson 5 the player typed a number and the Agent built to order. Do it again — but with fill, so there is no ceiling on the size.
- Press
Cand make a new chat command calledhall. - Click the (+) and rename the number to
size. - Guard it, as you learned in Lesson 6: anything under 3 or over 40 gets a message and no build.
- Otherwise build a hollow room whose walls are
sizeblocks long and 5 blocks high, on the ground where you are standing. - The far corner is the hard part. If one corner is at your own X, what is the other corner's X in terms of
size? The Math drawer has an add block. - Try
hall 5, thenhall 20, thenhall 40, thenhall 100.
It works if: hall 5 and hall 40 both build correct hollow rooms of visibly different sizes, hall 100 is refused with a message, and nothing in the program uses the Agent at all.
Why 40 is allowed and 100 is not
Notice what the guard is doing now. It is not protecting you from the Agent's bag — fill has no bag, and a 40 by 40 room is no harder for it than a 5 by 5 one.
The limit is yours. A room 100 blocks across would swallow the whole area you are working in and take a while to appear. You are guarding against a build that is unhelpful, not one that is impossible.
That is a step up from Lesson 6. There the program stopped you doing something that could not work. Here it stops you doing something that would work perfectly and still be a bad idea.