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.
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.district-code.txt on your Desktop. Next lesson, paste it back into a New Project.Need to log into Minecraft Education, Canva, or any other app that asks you to sign in? Most school and app accounts use the same login: your username is [email protected] (add a number if your name needs one, e.g. firstname.lastname2), and your password is the same one you use to log into your school computer.
Every project has at least one thing to hand in. Log into connect.det.wa.edu.au with your firstname.lastname and computer password, then head to your class and open the Submission section. Handing in more than one file? Zip them together first - total size must stay under 50MB.
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.
| 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 | ||||
tp. Code saved to your Desktop.C to open Code Builder, then choose Microsoft MakeCode from the list of coding appsT to open chat and type tp. Your Agent appears next to you and you see "Agent ready" in chattp again - the Agent follows you every time you use the commanddistrict-code.txt on your Desktop. Every lesson starts with this file, because the next laptop you use will not have your projectplayer.onChat("tp", function () {
agent.teleportToPlayer()
player.say("Agent ready")
})
square command that builds a sandstone outline, and your code saved to your Desktop.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)tp command (click after the last line, then Ctrl+V)square in chat and watch: the Agent walks a loop and lays a sandstone outline behind it3 in agent.move(FORWARD, 3) to a different number, then run square againdistrict-code.txt on your Desktopplayer.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)
}
})
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.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.farm - plants a 4 by 4 wheat patch - 16 seeds)farm and harvest.wall and house.lights.farm, harvest, lights and house are all quick to type.wall command that builds a wall of any size from two numbers typed in chat.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)width and height are numbers you type in chat after the command namewall 6 3. The Agent walks 4 blocks ahead first, so leave room. The first number is the width and the second is the heightdistrict-code.txt on your Desktopplayer.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)
}
})
DESTROY_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.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.farm command that tills and plants a full 4 by 4 patch of wheat seeds.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)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 row16 in agent.setItem(SEEDS, 16, 1)district-code.txt on your Desktopplayer.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)
}
})
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.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?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)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 4farm command. The moves are the same, and only the action changesfarm then harvest again to check the whole cycle works twicedistrict-code.txt on your Desktopplayer.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()
})
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)lights followed by your distance, for example lights 5. The Agent walks that many blocks, flips the lever and walks backwhile 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 youdistrict-code.txt on your Desktopplayer.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)
})
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.house command built on a function, with a finished house on your plot.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)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 movehouse 3 2 first. The first number is the side length and the second is how many layers high. Then try house 5 3district-code.txt on your Desktopfunction 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)
}
})
house 3 2, before you build a big one. A mistake on a small build is cheap to undo.buildRingtower 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?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)farm, harvest, lights, house) and check each one still worksdistrict-code.txt on your Desktopplayer.onChat("help", function () {
player.say("Commands: tp, farm, harvest, lights, house")
})
farm, house and lights live. If a command fails, say what you expected to happen, then try a fix from your debugging logdistrict-code.txt file and a short written reflection through ConnectAfter 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.
Join the world, open Code Builder // District 01