Time needed: 60 minutes
Materials needed:
Setup:
A computer program is a type of algorithm—a set of step-by-step instructions. The list of steps for telling the robot how to complete the task is an algorithm. Recipes and driving directions are algorithms, too!
Computer programs are written in code, a language that can be understood by machines. Programs use commands to tell a machine what to do. A command is one step in a program.
Activity:
You’ve been challenged to write programs a robot can follow to navigate two different mazes!
Part 1: Navigate a robot through a paper maze. (15 minutes)
First, write a program that will tell a robot how to solve the maze on the Robot Maze 1 handout.
The maze consists of a thick black line on a large sheet of white paper. The robot you’re writing this program for is designed to be follow a black line. Use regular language—you don't need to write commands in code yet.
To check if a program runs correctly, use the robot stand-in, moving it through the maze according to the program.
How did it go?
If you need help, check out Robot Maze 1 Solution for one sample program that a robot could follow to navigate the maze.
Want more challenge? Try this!
Pull out a map of your favorite hiking trail! Then, write a program a robot could follow to travel it.
Part 2: Write a program to navigate a robot through any simple maze. (45 minutes)
When programming with a computer language, it’s important to get the syntax exactly right. Syntax is the set of rules used by a language. It includes spelling, spacing, symbols, and punctuation.
To plan a program without worrying about syntax, programmers sometime use pseudocode. ("Pseudo" means fake.) Pseudocode uses commands in regular human language. It can then be translated into any kind of computer language. The only rule for pseudocode is that it should be easy to understand.
Next, write a computer program in pseudocode that tells a robot how to solve any simple maze. Read pages 1 and 2 of the Robot Maze 2 handout to learn about programming using conditionals, loops, and functions.
Then, translate the “Left Hand on Wall” method (on page 3 of the handout and below) into pseudocode. This program is often used for maze-solving robots. The rule is based on the idea that if you’re walking through a maze and always keep the same hand on the wall, eventually you’ll end up at the exit.
Here is what the rule says:
Write the rule in pseudocode on page 3 of the Robot Maze 2 handout.
Then, on page 4 of the handout, write a program using loops and conditional statements that can take a robot from the beginning to the end of any simple maze. The robot may take wrong turns, so it won't be as efficient as when you just gave it "driving directions" in part 1.
When the program is finished, test your program with the maze on page 5 of the handout, the same way you tested your program in part 1. Use the robot stand-in to move through the maze.
If the robot gets stuck before it reaches the end, debug the program by going over each step to find the error. Keep iterating, or repeating the process of testing and debugging, until the program works and the robot solves the maze!
Want a challenge? Try this!
Robots can run more than one program at the same time. For example, while the maze-solving program is running, the robot could also be running code that tells it to follow a line.
So, write pseudocode with conditional statements, loops, and functions to create a program that makes a robot follow the turns of a line.
To help, here's how line-following robots work:
And that’s it! You’ve now completed two steps of the Ambassador Programming Robots badge! If you had fun doing this, you might want to learn more about robots and design your own with the rest of the Ambassador Robotics badges.
Troop Leaders: The instructions for all badge steps are available free of charge in the Girl Scout Volunteer Toolkit.
Girl Scout Activity Zone activities have been adapted from existing Girl Scout programming.