Lesson plan

Build a Farm with Code & Math

Students solve area and perimeter word problems to design farm plots, then program their MakeCode Agent to construct the farm in Minecraft.

Build a Farm with Code & Math
Download lesson files
Ages
Ages 11-18
Essential question

How can mathematical calculations and computer programming work together to build a functional farm?

Overview

This project-based lesson combines mathematics with computer science. Students solve word problems involving area and perimeter to determine the dimensions of farm structures, crop fields, and animal pens, applying their calculations directly to spatial construction.

Using Microsoft MakeCode in a flat Minecraft world, students program their Agent helper to clear space, till land, and place blocks. Through iterative coding and visual documentation in their in-game journals, learners demonstrate their problem-solving and debugging process.

Learning objectives

By the end of this lesson students will be able to:

  • Solve word problems to calculate the area and perimeter of rectangular and square farm plots.
  • Program the Agent using loops and sequencing in MakeCode to build farm structures and fields.
  • Document mathematical reasoning and project progress using the in-game camera and journal.
  • Demonstrate a debugging mindset by preserving iterative coding attempts rather than erasing errors.

Blocks and items used in this lesson

Key vocabulary

Area
The total amount of flat space inside the boundary of a two-dimensional shape, measured in square units.
Perimeter
The total distance around the outside edge of a shape.
Agent
A programmable companion robot in Minecraft that can move, dig, and place blocks.
Active Slot
The specific inventory space in the Agent's backpack chosen for placing blocks into the world.
Sequence
The specific step-by-step order in which computer instructions run.

Before class

Lesson sequence

  1. Math and Coding Review

    Review basic formulas for perimeter and area. Remind students how the Agent operates, specifically that materials must sit inside the Agent inventory, the active slot must be set, and code can teleport the Agent if it gets lost.

  2. Calculating Dimensions

    Students read the math prompts for the farm shed, carrot patch, potato patch, beetroot patch, cow corral, and sheep corral. They solve for required measurements such as length, width, area, and perimeter before writing any code.

  3. Agent Construction and Debugging

    Students write code in MakeCode using sequences and loops to direct their Agent. If an attempt fails, students leave the faulty structure intact, move to an open space, and test revised code so their problem-solving process remains visible.

  4. Documentation and Export

    Using the camera and journal, students photograph each completed structure and write explanatory sentences detailing their math solutions. Students save their code file and export both their working world file showing past attempts and their final completed world file.

Assessment: success criteria

  • Correct mathematical solutions recorded in complete sentences inside the student journal.
  • Successful execution of Agent code using loops and sequential logic to construct all required farm sections.
  • Submission of the MakeCode file along with two distinct world files showing the trial-and-error process and final build.

Differentiation

Support

Provide a formula reference card and assist learners with checking the Agent active inventory slot before running code.

Stretch

Challenge students to optimize their MakeCode scripts by combining nested loops to plant and fence areas with fewer blocks of code.

Knowledge check

5 questions to check understanding after the lesson. Tap an answer to see if it is right; the score appears at the end.

  1. 1What must you do before directing the Agent to place a block in the world?

  2. 2What should students do if their code produces an error during construction?

  3. 3What are the dimensions given for the beetroot planting area?

  4. 4How do students record their answers to the math word problems?

  5. 5Which deliverables must students submit at the conclusion of the project?

Resources

Part of the Area and Perimeter curriculum

This is lesson 3 of 5 in Area and Perimeter.

  1. Area and Volume
  2. Area Functions
  3. Build a Farm with Code & Math
  4. Surface Area and Perimeter
  5. Volume World

Frequently Asked Questions

What prerequisite skills should students possess before starting this lesson?

Students should already be familiar with basic MakeCode navigation and core Agent commands, typically by completing the introductory Agent tutorial world prior to this assignment.

Why are students asked to submit two separate Minecraft world files?

One file contains the unfinished or flawed builds that demonstrate the student coding process and debugging steps, while the second file contains the polished, final farm build with completed journal notes.

What should students do if the Agent wanders off or gets lost?

Students can write and execute a short command in MakeCode to teleport the Agent directly back to the player location.

Adapted from Build a Farm with Code & Math by Perin Lal on Minecraft Education, last updated Jul 16, 2025. This classroom version, the timings and the quiz were written by 9Minecraft Education.

You May Also Like

9Minecraft Education is an independent teaching resource and is not affiliated with Mojang or Microsoft. Lesson plans here are our own classroom-ready adaptations; each one links to the original resource and credits its author. © 2026 9minecraft.net