Home
// Digital Technology - Year 9/10 //

AUTOMATION ARCHITECTS

Over the next 10 lessons your pair claims a district plot in our shared Minecraft Education town, then writes code that makes your Agent farm, build and switch on the lights for you. On District Tour Day you run your commands live.

🤖 Code Builder
🌾 Auto Farm
🏗️ Agent Builder
💡 Smart Lights
Your Toolkit
🗺️
The Shared World
We are all building inside City World 2, an official Minecraft Education map. Join through the picture-based Join Code in the Multiplayer tab of the Pause menu - your teacher hosts the world.
For teacher: download the map file here - City World.mcworld
🤖
Code Builder & Agent
Press C in Minecraft to open Code Builder, then choose Microsoft MakeCode. You write commands in JavaScript, and your Agent, a robot helper, carries them out when you type the command in chat.
⚠ Only run commands while you stand inside your own district. Your Agent can break blocks in its path.
👥
Your Pair & District
You'll work in a pair for the whole project. Your pair is assigned one plot in the town and it becomes your district: your farm, your building site and your lights all have to fit inside it.
💾
Saving Your Code
You use a different laptop every lesson, so Code Builder will not remember your project. At the end of every lesson, copy your code into Notepad and save it as district-code.txt on your Desktop. Next lesson, paste it back into a New Project.
🧠
AI Assistant
copilot.microsoft.com - ask it to explain a line of code, help you plan, or work out why a command is not doing what you expected.
⚠ AI makes up commands that MakeCode does not have, and often answers for Java Minecraft. Always paste its code into MakeCode and check it works.
🎪
District Tour Day Rules
On the final day the whole class walks the town district by district. Your pair types its commands live, one partner typing and the other explaining the code, while the Agent does the work.
// Primary Objective

Design and code an automated district on your plot, working as a pair. Your Agent has to farm, build and switch on the lights when you type a command, and you have to be able to explain how your code works.

Plan your district and a command for every job before you write any code
Code with loops, variables and a function, so one short command does the work of hundreds of clicks
Test every command, and log the bugs you find and how you fixed them
Present your district live on District Tour Day by running your commands in front of the class
// Marking Key & Rubric
Criteria Draft
(0-1)
Developing
(2-3)
Strong
(4)
Outstanding
(5)
Score
Planning & Design No command table, and the systems were chosen with no plan A basic plan and command table exist and were mostly followed Clear plan agreed by both partners, with a command table kept up to date Thoughtful district plan where every system has a clear purpose, explained on Tour Day / 5
Code & Logic Code pasted in with no changes, and the loops and numbers are not understood Commands work, and you can explain what the loops do Loops, a variable and a function used correctly, and changed to fit your district Clean, well-tested code you can explain line by line, plus your own extra command / 5
Automation Works Fewer than three systems work, or commands often fail Farm, builder and lights all work, with some retries All three systems work reliably every time you type the command All three work every time, and a helpful message shows when something is wrong / 5
Testing & Teamwork Little testing, and one partner did almost all the work Some testing and a short debugging log, and both partners contributed Debugging log shows problems found and fixed, and a confident joint tour Thorough testing, and useful feedback given to other pairs on Tour Day / 5
Total / 20
Scroll sideways to see every column
Build Log
Week 1
01
🤖 Meet Your Agent
▾
// DISTRICT OBJECTIVECode Builder open, your first command written, and your Agent teleporting to you whenever you type tp. Code saved to your Desktop.
  • Open Minecraft Education and join the class world using the picture-based Join Code shown on your teacher's screen (Multiplayer tab, Pause menu)
  • Find your pair's district plot, marked out by your teacher, and walk its full boundary together so you both know where it starts and ends
  • Press C to open Code Builder, then choose Microsoft MakeCode from the list of coding apps
  • Select New Project in the My Projects gallery, then click JavaScript at the top of the editor to switch to the code view
  • Click Copy on the code below, click inside the editor, press Ctrl+A then Ctrl+V to replace everything, then click Resume Game
  • Press T to open chat and type tp. Your Agent appears next to you and you see "Agent ready" in chat
  • Move a few blocks away and type tp again - the Agent follows you every time you use the command
  • Save your work before you leave: click in the code, press Ctrl+A then Ctrl+C, open Notepad, press Ctrl+V and save it over district-code.txt on your Desktop. Every lesson starts with this file, because the next laptop you use will not have your project
// Command tp - bring your Agent to you
player.onChat("tp", function () {
    agent.teleportToPlayer()
    player.say("Agent ready")
})
💡 HintIf Code Builder will not open, or the Agent does not appear, put your hand up - your teacher sets up Code Builder for the shared world.
// ASK AI"Explain this MakeCode line by line for a beginner: player.onChat("tp", function () { agent.teleportToPlayer() })"
02
🧭 Move & Turn
▾
// DISTRICT OBJECTIVEA square command that builds a sandstone outline, and your code saved to your Desktop.
  • Reload your work: press C, choose Microsoft MakeCode, start a New Project, click JavaScript at the top of the editor, then open district-code.txt from your Desktop and paste it in (Ctrl+A, then Ctrl+V)
  • Stand inside your own district, on flat ground, before you run any command - your Agent works from wherever you stand
  • Click Copy on the code below and paste it under your tp command (click after the last line, then Ctrl+V)
  • Type square in chat and watch: the Agent walks a loop and lays a sandstone outline behind it
  • Change the 3 in agent.move(FORWARD, 3) to a different number, then run square again
  • Count the lines: how many more would you need to write if there was no loop and you typed the move and the turn four times?
  • Save your work before you leave: click in the code, press Ctrl+A then Ctrl+C, open Notepad, press Ctrl+V and save it over district-code.txt on your Desktop
// Command square - a loop that walks a square
player.onChat("square", function () {
    agent.teleportToPlayer()
    agent.setAssist(PLACE_ON_MOVE, true)
    agent.setItem(SANDSTONE, 16, 1)
    agent.setSlot(1)
    for (let index = 0; index <= 3; index++) {
        agent.move(FORWARD, 3)
        agent.turn(LEFT_TURN)
    }
})
💡 HintThe loop says index <= 3, so it counts 0, 1, 2, 3 and runs 4 times. Four left turns bring the Agent back to the way it started.
// ASK AI"What is a loop in programming? Explain it with a robot that walks around a square."
// LEVEL UPWork out how many blocks a bigger square needs (4 sides x the side length) and raise the 16 in agent.setItem(SANDSTONE, 16, 1) so the Agent has enough, with a couple to spare. Then run a square with sides of 5.
Week 2
03
📐 Plan Your District
▾
// DISTRICT OBJECTIVEA checked district plan and command table, agreed by both partners, that fits inside your plot.
  • As a pair, decide what your district is (a farming town, a workshop, an eco-village) and give it a name
  • Choose what your Agent will automate. Every pair builds the first three systems below, and the fourth is your own idea
  • Sketch a top-down plan on paper or in Canva showing your farm patch, your building site, and where your lamps and lever go
  • Write a command table with one row per chat command: its name, what it does, and what the Agent needs (for example farm - plants a 4 by 4 wheat patch - 16 seeds)
  • Check every system has its own space inside your plot, with room for you to stand at a control post, so the Agent never runs into another system
  • Get your plan and command table checked by your teacher before you write any more code
🌾 Auto FarmThe Agent tills the soil and plants seeds in neat rows, then harvests the crop. Commands: farm and harvest.
🏗️ Agent BuilderThe Agent builds walls and a house from numbers you type in chat, using loops and a function. Commands: wall and house.
💡 Smart LightsA lever switches your redstone lamps, and the Agent flips the lever on command. Command: lights.
🧩 Your Own SystemAn extra job of your pair's own design, built only from commands you have already met. Planned now, built if you have time.
💡 HintShort command names are the easiest to type in chat. farm, harvest, lights and house are all quick to type.
// ASK AI"Help me plan a small automated Minecraft district with a farm, a builder and a lighting system. What jobs could a robot helper do in each part?"
📤 Submit via ConnectA photo or Canva sketch of your district plan, with your command table
04
🧱 Loops & Walls
▾
// DISTRICT OBJECTIVEA wall command that builds a wall of any size from two numbers typed in chat.
  • Reload your work: press C, choose Microsoft MakeCode, start a New Project, click JavaScript at the top of the editor, then open district-code.txt from your Desktop and paste it in (Ctrl+A, then Ctrl+V)
  • Stand inside your own district, on flat ground, before you run any command - your Agent works from wherever you stand, with a clear patch of ground in front of you
  • Read the code first: width and height are numbers you type in chat after the command name
  • Click Copy and paste the wall code under your other commands
  • Type wall 6 3. The Agent walks 4 blocks ahead first, so leave room. The first number is the width and the second is the height
  • Try two more sizes and write down how many blocks each one needs (width x height)
  • Point to the line that makes the Agent climb a layer, and the line that turns it around. Explain to your partner why it needs two turns
  • Save your work before you leave: click in the code, press Ctrl+A then Ctrl+C, open Notepad, press Ctrl+V and save it over district-code.txt on your Desktop
// Command wall - width and height from chat
player.onChat("wall", function (width, height) {
    agent.teleportToPlayer()
    agent.move(FORWARD, 4)
    agent.setAssist(PLACE_ON_MOVE, true)
    agent.setAssist(DESTROY_OBSTACLES, true)
    for (let index = 0; index < height; index++) {
        agent.setItem(MOSSY_STONE_BRICKS, width, 1)
        agent.move(FORWARD, width - 1)
        agent.move(UP, 1)
        agent.turn(LEFT_TURN)
        agent.turn(LEFT_TURN)
    }
})
💡 HintDESTROY_OBSTACLES lets your Agent break blocks in its way. Only run this in your own district, or it can knock down a neighbour's build.
// ASK AI"In a Minecraft MakeCode program, what does the width in player.onChat("wall", function (width, height) mean? How do the numbers I type in chat get into it?"
// LEVEL UPPredict what wall 3 6 will build before you run it, then check. Then change MOSSY_STONE_BRICKS to a different block: click Blocks at the top, pick a new block in the drop-down, then click JavaScript again to read its name.
Week 3
05
🌾 Farm Bot
▾
// DISTRICT OBJECTIVEA farm command that tills and plants a full 4 by 4 patch of wheat seeds.
  • Reload your work: press C, choose Microsoft MakeCode, start a New Project, click JavaScript at the top of the editor, then open district-code.txt from your Desktop and paste it in (Ctrl+A, then Ctrl+V)
  • Pick a flat, open patch inside your district for the farm. The ground must be plain grass or dirt, because that is all the Agent can till, and wheat needs light to grow, so keep it out of the shade and away from caves
  • Stand on the block where the farm will start and mark that block with a different coloured block, so you can find the exact spot again next lesson
  • Click Copy and paste the farm code under your other commands
  • Type farm in chat. For every step of the inner loop the Agent moves left, tills the ground, then plants a seed, and the outer loop repeats that for each row
  • Work out how many seeds 4 rows of 4 need, then check it against the 16 in agent.setItem(SEEDS, 16, 1)
  • Save your work before you leave: click in the code, press Ctrl+A then Ctrl+C, open Notepad, press Ctrl+V and save it over district-code.txt on your Desktop
// Command farm - a loop inside a loop
player.onChat("farm", function () {
    agent.teleportToPlayer()
    agent.setItem(SEEDS, 16, 1)
    agent.setSlot(1)
    agent.setAssist(DESTROY_OBSTACLES, true)
    for (let row = 0; row < 4; row++) {
        for (let col = 0; col < 4; col++) {
            agent.move(LEFT, 1)
            agent.till(FORWARD)
            agent.place(FORWARD)
        }
        agent.move(BACK, 1)
        agent.move(RIGHT, 4)
    }
})
💡 HintTilled soil but no seeds? Try the other pattern from Minecraft Education's own coding course: agent.till(FORWARD), then agent.move(FORWARD, 1), then agent.place(DOWN). Crops also grow faster on farmland that is hydrated, so a water block beside your patch is worth adding.
// ASK AI"Explain what a nested loop is, using a farm with rows and columns as the example."
// LEVEL UPMake the farm bigger with a variable. Add let size = 5 above the command, swap both 4s in the loops for size, change agent.move(RIGHT, 4) to agent.move(RIGHT, size), and change the seed count to size * size. How many seeds does it plant now?
06
🔍 Harvest & Debug
▾
// DISTRICT OBJECTIVEA working farm and harvest cycle, and a debugging log with at least two problems you found and fixed.
  • Reload your work: press C, choose Microsoft MakeCode, start a New Project, click JavaScript at the top of the editor, then open district-code.txt from your Desktop and paste it in (Ctrl+A, then Ctrl+V)
  • Check your farm from Build 05. Fully grown wheat is tall and golden. Breaking wheat that is not fully grown only gives you a seed back, and ripe wheat gives wheat and seeds
  • Click Copy and paste the harvest code under your other commands
  • Test on one row first: change the outer 4 to 1, stand on the block you marked in Build 05, then type harvest. Check the crops break and the farmland stays. Then change the 1 back to 4
  • Debug it: if the Agent breaks the wrong thing or ends up in the wrong place, compare the loops with your farm command. The moves are the same, and only the action changes
  • Keep a debugging log with three columns: what happened, what you expected, what you changed. Write at least two rows
  • Run farm then harvest again to check the whole cycle works twice
  • Take a screenshot of your farm and of your code: press the Print Screen key, drag around the area and the snip is saved to your Screenshots folder
  • Save your work before you leave: click in the code, press Ctrl+A then Ctrl+C, open Notepad, press Ctrl+V and save it over district-code.txt on your Desktop
// Command harvest - the same path, a different action
player.onChat("harvest", function () {
    agent.teleportToPlayer()
    agent.setAssist(DESTROY_OBSTACLES, true)
    for (let row = 0; row < 4; row++) {
        for (let col = 0; col < 4; col++) {
            agent.move(LEFT, 1)
            agent.destroy(FORWARD)
        }
        agent.move(BACK, 1)
        agent.move(RIGHT, 4)
    }
    agent.collectAll()
})
💡 HintChange one thing at a time and run the command again. If you change three things at once you will not know which one fixed it.
🔍 Google Image Search"minecraft wheat growth stages"
// ASK AI"My Minecraft MakeCode Agent harvested the wrong blocks. Here is my code: [paste your code]. What could be wrong?"
📤 Submit via ConnectA screenshot of your farm growing and a screenshot of your farm and harvest code
Week 4
07
💡 Light Switch
▾
// DISTRICT OBJECTIVEA lever and lamps that your Agent switches on and off with one chat command.
  • Reload your work: press C, choose Microsoft MakeCode, start a New Project, click JavaScript at the top of the editor, then open district-code.txt from your Desktop and paste it in (Ctrl+A, then Ctrl+V)
  • Build at least three redstone lamps in your district and wire them to a lever with redstone dust. Place the lever on the face of a wall block
  • Test it by hand first: flip the lever yourself and check every lamp lights up and goes dark again
  • Choose a control post, the spot where you will stand, in a straight line from the lever. Count the empty blocks between you and the lever - that number is your distance
  • Click Copy and paste the lights code under your other commands
  • Type lights followed by your distance, for example lights 5. The Agent walks that many blocks, flips the lever and walks back
  • Read the code: the while loop walks one block at a time and stops early if a solid block is in the way, and the if and else decide whether to flip the lever or warn you
  • If chat says "Something is in the way - check the distance", your number is too big. If nothing happens at all, it is too small. Fix your number and try again
  • Run the same command a second time and see what happens to the lamps
  • Save your work before you leave: click in the code, press Ctrl+A then Ctrl+C, open Notepad, press Ctrl+V and save it over district-code.txt on your Desktop
// Command lights - while, if and else
player.onChat("lights", function (distance) {
    agent.teleportToPlayer()
    let steps = 0
    while (steps < distance && !agent.detect(AgentDetection.Block, FORWARD)) {
        agent.move(FORWARD, 1)
        steps += 1
    }
    if (steps < distance) {
        player.say("Something is in the way - check the distance")
    } else {
        agent.interact(FORWARD)
    }
    agent.move(BACK, steps)
})
💡 HintPut the lever on the face of a solid wall block, so the lever is the last thing before the wall. A lever flips between on and off each time it is used, so the same command turns your lights on the first time and off the second.
// ASK AI"How do I wire redstone lamps to a lever in Minecraft Bedrock Edition? Give me a simple layout." (Say Bedrock, because AI often answers for Java.)
// LEVEL UPAdd a door to your district and make the Agent open it. agent.interact(FORWARD) opens a door in front of the Agent, and agent.move(FORWARD, 2) walks it through. Write a new gate command that does both.
08
🏠 Functions & House
▾
// DISTRICT OBJECTIVEA house command built on a function, with a finished house on your plot.
  • Reload your work: press C, choose Microsoft MakeCode, start a New Project, click JavaScript at the top of the editor, then open district-code.txt from your Desktop and paste it in (Ctrl+A, then Ctrl+V)
  • Read the code first: buildRing is a function, a named set of steps you can reuse. The house command calls it once for every layer. This time the Agent places a block behind itself after every step with agent.place(BACK), instead of using place on move
  • Click Copy and paste both parts under your other commands, with the function first
  • Stand inside your own district, on flat ground, before you run any command - your Agent works from wherever you stand
  • Type house 3 2 first. The first number is the side length and the second is how many layers high. Then try house 5 3
  • Predict the size before you run a new number. The Agent gets a fresh stack of 64 blocks every layer, so keep the side at 16 or less
  • Finish the house by hand: add a roof, a door and windows. The code builds the shell fast and you make it look like a place
  • Explain to your partner why the function means you do not have to copy the same four lines again and again
  • Save your work before you leave: click in the code, press Ctrl+A then Ctrl+C, open Notepad, press Ctrl+V and save it over district-code.txt on your Desktop
// Command house - a function called in a loop
function buildRing(side: number) {
    for (let index = 0; index < 4; index++) {
        for (let step = 0; step < side; step++) {
            agent.move(FORWARD, 1)
            agent.place(BACK)
        }
        agent.turn(LEFT_TURN)
    }
}

player.onChat("house", function (side, height) {
    agent.teleportToPlayer()
    for (let layer = 0; layer < height; layer++) {
        agent.setItem(SANDSTONE, 64, 1)
        agent.setSlot(1)
        buildRing(side)
        agent.move(UP, 1)
    }
})
💡 HintTest a small house first, like house 3 2, before you build a big one. A mistake on a small build is cheap to undo.
// ASK AI"What is a function in programming, and why would I use one in a Minecraft MakeCode Agent program?"
📤 Submit via ConnectA screenshot of your finished house and a screenshot of your code showing buildRing
// LEVEL UPWrite a second command called tower that reuses buildRing with a small side length and a tall height. How many new lines did you need, now that the function already exists?
Week 5
09
🤝 Test & Polish
▾
// DISTRICT OBJECTIVEEvery command tested by another pair, at least one fix made, and your tour rehearsed.
  • Reload your work: press C, choose Microsoft MakeCode, start a New Project, click JavaScript at the top of the editor, then open district-code.txt from your Desktop and paste it in (Ctrl+A, then Ctrl+V)
  • Run every command once (farm, harvest, lights, house) and check each one still works
  • Demo your commands to another pair using your command table, while they try to break them with wrong numbers or by standing in the wrong spot
  • Watch the other pair's demo and give them honest, specific feedback on what worked and what confused you
  • Click Copy and paste the help command under your others, and edit the list so it matches every command you actually have
  • Fix at least one problem the other pair found, and update your command table so it says what each command really does
  • Tidy your district: remove test builds and stray blocks, and add signs so a visitor knows what each area is
  • Rehearse your tour: decide which partner types each command and which partner explains which piece of code
  • Save your work before you leave: click in the code, press Ctrl+A then Ctrl+C, open Notepad, press Ctrl+V and save it over district-code.txt on your Desktop
// Command help - list your commands in chat
player.onChat("help", function () {
    player.say("Commands: tp, farm, harvest, lights, house")
})
💡 HintTry to break your own commands before someone else does. Type a strange number, or stand in the wrong spot, and see what your Agent does.
// ASK AI"What specific, useful feedback can I give a classmate about their Minecraft MakeCode program, instead of just saying it works?"
📤 Submit via ConnectYour final command table, updated to match what each command really does
10
🎪 District Tour Day
▾
// DISTRICT OBJECTIVERan your commands live on District Tour Day, and submitted your screenshot, code file and reflection.
  • Reload your code before class starts and test each command once, so you know they work
  • Format briefing: the whole class walks the town together, district by district, in the order set by your teacher
  • At your district, one partner types the commands while the other explains what the code does. Swap roles halfway
  • Run farm, house and lights live. If a command fails, say what you expected to happen, then try a fix from your debugging log
  • Point out one line of code you are proud of and explain in one sentence what it does
  • Watch every other pair's tour and note one automation idea you would like to try next time
  • Submit a screenshot of your district, your district-code.txt file and a short written reflection through Connect
💡 HintSay what you expect to happen before you type each command. It shows you understand your code, even if the game surprises you.
// ASK AI"Help me write a short reflection about what I learned coding a Minecraft Agent with a partner, including one bug we fixed."
📤 Submit via ConnectA screenshot of your district, your final code as a text file, and your written reflection. Zip them together if you are handing in more than one file
🏭

The District Runs Itself

After 10 lessons, every pair's district comes to life. On District Tour Day the class walks the town together while each pair types its commands and the Agent farms, builds and flips the switch.

🚶 District tour
⌨️ Live commands
🤖 Agents at work

Join the world, open Code Builder // District 01

SYSTEM ONLINE // YEAR 9/10 DIGITAL TECHNOLOGY AUTOMATION ARCHITECTS // 10 DISTRICTS