Jump to main content

Program a Maze with Paper

Summary

Key Concepts
Problem solving
Credits
Ben Finio, PhD, Science Buddies
A screenshot of a maze and directions on how to finish it

Introduction

You probably use computer programs every day. Every time you use the internet, play a video game, or us a smartphone, you are using computer programs. Do you want to learn a little bit about computer programming, without the need to actually use a computer? In this fun activity, you will write a “program” – a set directions for a volunteer to find their way through a maze. Can you help them find their way through without crashing?

This activity is not recommended for use as a science fair project. Good science fair projects have a stronger focus on controlling variables, taking accurate measurements, and analyzing data. To find a science fair project that is just right for you, browse our library of over 1,200 Science Fair Project Ideas or use the Topic Selection Wizard to get a personalized project recommendation.

Background

A computer program is a list of instructions or commands that tell a computer what to do. For example, when you are typing on a computer, there are commands that tell it to display certain characters on the screen when you push a key on your keyboard. The program for a video game might have different instructions that tell the game to move the on-screen character when you push the joystick on a controller. A web browser has instructions to tell it what to do when you use your mouse to click on different buttons. There are many, many more examples of what computer programs can do. Can you think of more?

Computers are very good at following directions, but that can lead to one problem. What happens if a human programmer accidentally gives a computer the wrong directions? The computer can’t think for itself – it will go ahead and follow the directions it was given, even if they’re wrong! This can cause the program to “crash,” or not function as it was intended. Computer programmers call errors in computer code “bugs,” and the process of finding and removing them “debugging.” In this project, you will write a set of directions for a volunteer to navigate a maze, using commands like “move forward,” “turn left,” and “turn right.” If you make a mistake with your directions, the volunteer will “crash” into the wall of the maze, and you will have to debug your program and try again!

Materials

  • Graph paper
  • Ruler
  • Pencil
  • Volunteer

Preparation

  1. Use a sheet of graph paper to create a small maze that fits on a rectangular grid. All of the maze’s walls should be vertical or horizontal – no diagonal or curved lines.
  2. Start out with a small, easy-to-solve maze, and you can make a more difficult one later.
  3. Make sure the maze has clearly labeled “start” and “finish” points.
  4. Optional: you can also use a coloring or activity book that contains mazes, as long as it has some mazes with only vertical and horizontal lines.

Instructions

  1. Imagine that you are a person walking through your maze, starting at the “start” point. On a separate piece of paper, write down directions, one step at a time, for how you would walk through the maze. For example, use commands like “Move forward 2 squares,” “turn left,” and “turn right.” Continue writing directions until you have enough to reach the “finish” mark of the maze. Optional: if you prefer, you can draw arrows instead of writing out the words (a straight arrow for “move forward,” and curved arrows for turning).
  2. Now, hand your maze, the directions, and pencil to your volunteer. Instruct them to follow your directions exactly as they go through the maze, even if they see a mistake. They are not allowed to solve the maze on their own or change the directions.
  3. Watch closely to see if the volunteer successfully completes the maze by following your directions. Do they crash into any of the walls, or do they make it all the way to the finish line?
  4. If your volunteer makes it all the way to the finish line, then congratulations! Your program did not have any bugs. Try making a bigger, more complicated maze, and starting over.
  5. If your volunteer crashed into one of the maze’s walls, you need to debug your program. Carefully trace through your program step by step to see where things went wrong. Did you tell them to move one block too far, or turn one block too early? Just one mistake can throw off your entire program and cause a crash later on, so look carefully!
  6. After you discover the bug, re-write your program. If you only need to change one or two steps, you can just erase them instead of re-writing the whole thing (this is one of the advantages of programming on a real computer – it is very easy to delete and re-write text!).
  7. Have your volunteer try the maze again, following your new program. Can they solve it this time? If not, keep debugging your program until they can solve the maze.

Extra: computer programs are written in many different “languages,” which all have slightly different formats, but very similar underlying concepts. For example, some computer programs use punctuation and spelling differently – this is called the program’s “syntax.” For this project, can you come up with a different “language” that accomplishes the same task of solving the maze? For example, what about using commands that are defined relative to absolute directions on the piece of paper like “move up,” “move down,” “move left,” and “move right;” as opposed to turning left/right as if you were a person standing in the maze? Can you see how, although these two languages are different, they can both be used to do the same thing?

Extra: can you try the project with more complicated mazes that include diagonal or curvy lines? If you can no longer rely on a rectangular grid for movement, how would you write the program? Hint: try introducing new commands like “move forward until you reach an intersection” or “move forward until you hit a wall.”

Extra: instead of using a maze on paper, write a program to navigate a person walking through your house or school. Can they move from room to room without bumping into a wall by only following your directions?

Observations and Results

You probably found that it only takes one bug early on in a program to cause a crash. When solving a maze, there is little room for error – make one wrong turn, and you can bump into a wall or get lost! You might have noticed the same thing if you have ever been riding in the car with an adult attempting to follow directions from a GPS system.

Have you ever used a computer program that crashed, or played a video program with a glitch? Did you find the experience frustrating? This is why companies do lots of debugging and testing before they release a program to the public, and sometimes have to release patches to update a program after a bug is discovered.

icon scientific method

Ask an Expert

Curious about the science? Post your question for our scientists.

Additional Resources

Careers

Career Profile
Are you interested in developing cool video game software for computers? Would you like to learn how to make software run faster and more reliably on different kinds of computers and operating systems? Do you like to apply your computer science skills to solve problems? If so, then you might be interested in the career of a computer software engineer. Read more
Career Profile
Computers are essential tools in the modern world, handling everything from traffic control, car welding, movie animation, shipping, aircraft design, and social networking to book publishing, business management, music mixing, health care, agriculture, and online shopping. Computer programmers are the people who write the instructions that tell computers what to do. Read more
Career Profile
Have you watched "The Transformers" cartoon series or seen the "Transformers" movies? Both shows are about how good and evil robots fight each other and the humans who get in the middle. Many TV shows and movies show robots and humans interacting with each other. While this is, at present, fantasy, in real life robots play a helpful role. Robots do jobs that can be dangerous for humans. For example, some robots defuse landmines in war-stricken countries; others work in harsh environments like… Read more
Career Profile
Robots are no longer futuristic machines. Robots are here and now and are used in manufacturing, health care, service industries, and military applications. They perform tasks that are repetitive and hazardous—things that humans don't want to do or are unsafe to do. But robots are still machines, which means they require humans to build, maintain, program, and keep them functioning efficiently. Robotics technicians work with robotics engineers to build and test robots. They are… Read more
Career Profile
Have you ever seen an assembly line in a factory on TV? Or have you ever gone on a factory tour? Did you notice all of the conveyor belts and machines working so quickly together? Advanced manufacturing technicians make sure all of these machines keep running. They maintain and repair the electrical and mechanical parts of these machines. They know how fluid systems, like pumps, and gas systems work. Gas systems use compressed air to power machines to clamp, stack, and move items. Technicians… Read more

Reviews

Reviews

|
Science Buddies |
Was this review helpful?
Top
Free science fair projects.