Chicken or the Egg

Chicken or the Egg

11-13 yrs old

Computer Science

Math & Economics


Use Code Builder and build a testing area to determine if free range chickens lay more eggs.

avatar Submitted By: John Miller

January 25, 2019

Download Assets


  • Critical Thinking

Supporting Files

World File

World file for student use

Learning Objectives

  • Students will understand how to use agent build commands.
  • Students will understand the role of position in placing blocks.
  • Students will be able to successfully run the block clone command.
  • Students will understand repeat loops.
  • Students will analyze and interpret data to determine similarities and differences in findings. (NGSS MS-ETS1-3)

Guiding Ideas

Before beginning, students should have some experience and success with writing simple code using Code Builder and should be able to access player, blocks, agent, and loop commands.

Loops can drastically cut down on the amount of code needed to run a command.

The agent can be used to recognize, place, and remove blocks quickly and efficiently.

Analyzing and interpreting data are foundational skills from which evidence can be derived to support claims.

Student Activities

Teachers may run this lesson with individual students, or with small groups based on their familiarity with Code Builder commands.

Students are to use their agent and chat commands to complete an experimental test location and then run an experiment to determine if chickens lay more eggs when provided with more space.

Specifically, they will task their agent with building a fence around both a 5x5 area and a 10x10 area. They will then use a clone command to copy an existing chicken coop and place multiple copies in a row. Finally, they will use chat commands to spawn chickens into each test area and run the experiment.

1. Use the agent to build fencing around the 5x5 and 10x10 areas. Students should explore, compare, and share command options and configurations. They should be able to complete this task by combining the following player, agent, and loop commands:

  • on chat command
  • agent teleport to player
  • agent [place on move] <true>
  • agent move [forward] by x
  • agent turn [left or right]
  • repeat 4 times do

2. Clone the existing chicken coop and make 4 copies. There are two ways to approach this and student understanding of position/coordinates will likely determine the choice they make. Both approaches use the clone command. They will be able to complete this challenge by embedding the following blocks command into a chat command:

  • Clone from ~x ~y ~z to ~x ~y ~z into ~x ~y ~z mask[replace] mode [normal]

This option requires that the player determine their relative position to the chicken coop in front of them. Entering the three-dimensional positions of the from and to values will capture a cuboid of the coop. The into values represent the location the player will place the cuboid relative to themselves.

The second option replaces ~x ~y ~z to ~x ~y ~z into ~x ~y ~z with a position sub-command.

  • Clone from [world] 0 0 0 to [world] 0 0 0 into [world] 0 0 0 mask[replace] mode [normal]

To use this command students will insert the world coordinates of the lower left corner of the coop and the upper right corner. They then move to the location where they want the next coop to appear and enter in the new coordinates.

3. With the experiment ready to begin, students should generate one final command that will spawn 5 chickens next to the player. They will perform this action twice, once inside the 5x5 area and again in the 10x10 area:

  • spawn [chicken] at ~0 ~0 ~0 (This is a Mobs command)
  • repeat x times

Note: In addition to placing 5 chickens into each fenced area, students should use a chicken spawn egg to spawn one chicken into each coop. Chicken eggs will be collected in the chest.

With preparations complete, run the experiment for a set amount of time (~10 minutes) and have students count and record the number of eggs found in each station or chest. They can produce individual reports, or add all their observations into one large data set for comparison and analysis.

Performance Expectations

Students will demonstrate their understanding of agent and loop commands by building two fences of different perimeter.

They will demonstrate understanding of positions and coordinates by successfully placing 4 chicken coops adjacent to each other.

Four chicken coops will be created using the clone command.

Through observation, students will produce individual and collective data sets that will allow them to determine similarities and differences in their findings.

Students should be able to answer the following questions:

  • How can loop commands be used to produce shorter code?
  • Do chickens with more space produce more eggs?
  • How is relative position different from world coordinates?


  • Critical Thinking

Supporting Files

World File

World file for student use