Robot Race
Overview
Students work in teams to write code that will direct their “real-life” robot to the finish line.
Divide the class into two teams and assign each team to a TA. Write instantiation code for them (i.e. Robot taName = new Robot();
) on each team’s half the whiteboard. Decide on the “finish point” for the robot race, then position the TAs so that it will take several turn and move commands to get them to get there.
When the race starts, students take turns writing a single line of code on the whiteboard. To execute the last line of code, the student says “semicolon”, which prompts the teacher to read that line of code to the TA. The first team to navigate their robot to the finish line wins.
Before Class
Materials: Whiteboard, markers, 2 TAs
Prep: Make sure the TAs understand
- Take commands from the teacher only, not the students
- “Turn” commands are clockwise
- Follow commands exactly, even if it means repeatedly walking into a wall/chair/etc.
Class Time
Intro: Computers only do exactly what you tell them to do. They’re not as smart as a person! You could tell a person “go to the door” and they’d understand you. Computers need that broken down into steps. We’re going to practice this with a robot who only knows how to turn and how to move forward.
Explain that
Robot anthony = new Robot(); //use the name of your TA
Makes a new robot and makes sure it has a name so we can give it commands.
Demo giving a move command (e.g. “Anthony, move 5”) and Anthony taking 5 heel-to-toe steps, then write the Java version (e.g. anthony.move(5);
). Explain the period, parentheses, and semicolon, having the students find the symbols on their keyboards after talking about each one.
Repeat with turn command. If students aren’t familiar with degrees, do a quick explanation and have them stand up as a class and practice turning various degrees.
Divide the class into (at least) two teams and assign each team a TA. Set up the whiteboard with a line down the middle so it looks like
Robot anthony = new Robot() | Robot otherTA = new Robot(); |
Decide on the “finish point” for the robot race, then position the TAs so that it will take several turn and move commands to get them to get there. Tell the students they will work together to get their robot to the finish line, but that the pen must pass to the next team member after each line of code.