Full teaching narration is free with Private Starter.Create free account
Back to curriculum
Computer ScienceGrade 3· U.S. National — Common Core & NGSS
Aligned to:U.S. educational frameworks

Build and Debug a Classroom Robot Algorithm

Students write, test, and improve a sequence of movement commands while collaborating respectfully and following shared classroom rules.

Build and Debug a Classroom Robot Algorithm

Illustrations are auto-generated and may be placeholders. They can be refreshed to match the narration.

Full teaching narration is included free with a Private Starter account.Create free account

What Is an Algorithm?

An algorithm is a sequence of steps for completing a task or solving a problem. The steps must be in a clear order so that someone, or a robot, can follow them. Imagine a robot facing a bookshelf. An algorithm might say, “Move forward two squares. Turn right. Move forward one square. Stop.” If you change the order, the robot may end in a different place. Computers and robots do not guess what you mean. They follow the commands they receive. Before writing an algorithm, identify the starting point, the goal, and any obstacles or rules. Then plan one step at a time. A useful algorithm is clear, complete, and possible to follow. If it does not work at first, you can test it and improve it.

A robot stands on a classroom grid with a marked start, a bookshelf goal, a chair in the way, and a planned path.
A robot stands on a classroom grid with a marked start, a bookshelf goal, a chair in the way, and a planned path.Source: Illustrated for this lesson

Create Movement Commands

Movement commands tell the robot exactly what action to perform. Your class can use commands such as “move forward one square,” “turn left,” “turn right,” and “stop.” A turn changes the direction the robot faces, but it does not move the robot into a new square. First, look at the grid and trace a path with your finger. Then write one command card for each action in the order it should happen. For example, if the robot faces east and the goal is two squares east and one square north, the commands could be: move forward, move forward, turn left, move forward, stop. Check that every command follows the shared classroom rules. The robot must remain on the grid, avoid obstacles, and use only the allowed commands.

A grid shows a robot facing east, a goal to the north, and five ordered movement command cards beside the path.
A grid shows a robot facing east, a goal to the north, and five ordered movement command cards beside the path.Source: Illustrated for this lesson

Test the Robot Path

Testing means following the algorithm exactly to see what happens. Place the robot on the starting square and point it in the starting direction. One teammate reads the commands, one moves the robot, and another checks the path. After each command, pause and confirm the robot’s square and direction. Do not add an unlisted move, even if you know where the robot should go. For example, suppose the commands say, “Move forward, turn right, move forward.” If the robot reaches an obstacle after the last move, record where the problem happened. The test gives your team evidence about the algorithm. It is not a failure when the path is wrong. Careful testing helps you make sense of the problem and decide what to improve next.

Three children test a robot on a grid while reading cards, moving the robot, and checking a path that ends at an obstacle.
Three children test a robot on a grid while reading cards, moving the robot, and checking a path that ends at an obstacle.Source: Illustrated for this lesson

Find and Fix Bugs

A bug is an error in an algorithm that causes an unwanted result. Debugging means finding the error, changing the algorithm, and testing it again. Begin at the first command and compare each expected move with the robot’s actual move. Look for a missing command, an extra command, a wrong turn, or commands in the wrong order. For example, a robot may turn right when it needs to turn left to avoid a chair. Replace “turn right” with “turn left,” then restart from the original starting point and retest the entire sequence. Change one part at a time so you can tell whether the change helped. Debugging often takes more than one try. Stay patient, use evidence from each test, and keep improving the sequence until it meets the goal and follows all constraints.

A robot path diagram contrasts the planned route with a wrong turn toward a chair and shows the corrected command.
A robot path diagram contrasts the planned route with a wrong turn toward a chair and shows the corrected command.Source: Illustrated for this lesson

Compare Solutions

A problem can have more than one successful algorithm. Teams should compare solutions using the same criteria and constraints. Criteria describe what a good solution should accomplish, such as reaching the goal safely. Constraints are limits or rules, such as avoiding blocked squares and using no more than eight commands. For example, Algorithm A reaches the goal in seven commands, while Algorithm B reaches it in five commands. Both avoid the obstacle, so both work, but Algorithm B is shorter. A shorter path may be preferred if using fewer commands is a criterion. However, do not choose a path only because it is fast. It must follow every rule. Listen as each team explains its evidence, ask respectful questions, and decide which solution best meets the agreed-upon criteria and constraints.

Two color-coded robot paths reach the same goal while a comparison chart shows seven commands for one and five for the other.
Two color-coded robot paths reach the same goal while a comparison chart shows seven commands for one and five for the other.Source: Illustrated for this lesson

Reflect on Teamwork Rules

Teams solve problems best when everyone follows fair and respectful rules. Take turns speaking, listen without interrupting, share materials, and invite each person to contribute an idea. These actions show civic virtues such as respect, honesty, responsibility, patience, and fairness. Democratic principles also help a group make decisions. Everyone should have a voice, and the team can use evidence, discussion, or a fair vote when members disagree. For example, if two robot paths work, each teammate can explain which path better meets the criteria. The group listens, asks questions, and then chooses a path together. After the activity, reflect on your teamwork. Ask, “Did we include everyone? Did we follow our roles? Did we disagree respectfully?” Improving teamwork rules helps the classroom community solve future problems together.

A diverse group shares robot materials, listens to each speaker, studies two paths, and votes together.
A diverse group shares robot materials, listens to each speaker, studies two paths, and votes together.Source: Illustrated for this lesson