CMPSC101 Fall 2026 :: DataStructures
  • Home
  • Interactive
  • Playground
  • Materials
  • JupyterLite

On this page

  • Overview
  • How to use this tool
  • Discussion questions for after the activity

Programming a Robot to get Through Through a Maze

activity
computational-thinking
instruction coding
debugging
Published

August 26, 2026

Overview

This activity is to use instructions to guide a robot through a maze. Because the robot follows instructions literally, it’s a great way to teach the importance of precision in programming!

  • The programmer builds a list of instructions using only the UP, DOWN, LEFT, and RIGHT buttons below.
  • Clicking on Run Robot allows you to see whether the instructions actually get the robot to the end of the maze. Remember, robots interpret things literally and they only follow instructions that are given to them. If the robot hits a wall, it will stop and report which instruction failed and where.

How to use this tool

  1. Choose a grid size and a seed, then click Generate Maze. The same seed + size always produces the same maze — great for giving every group an identical challenge, or for having students trade seeds with each other.
  2. Click UP, DOWN, LEFT, RIGHT to build up the instruction list for the green robot (top-left) to reach the red goal (bottom-right).
  3. Use Undo Last or Clear All to edit the instruction list.
  4. Click Save Instructions to download the list as a .txt file — this is the “program” the tester will run.
  5. Click Load Instructions to load a saved .txt file (handy for swapping programs between groups).
  6. Click ▶ Run Robot to test the instructions. Watch the robot move step-by-step. If it hits a wall, the wall is highlighted in red and a message explains exactly which instruction caused the problem.
  7. Click 🧭 Solve Maze to have the tool automatically compute a shortest instruction set and fill in the list — handy for showing an answer key or checking whether a shorter solution exists.
Start Goal Robot Blocked wall
Instructions

    Discussion questions for after the activity

    • Which types of instructions (UP/DOWN/LEFT/RIGHT) were most often used in your group’s solution? Why do you think that is?
    • What types of mazes required the most instructions to solve? Why do you think that is?
    • Could you tell before running the program that an instruction would fail, just by looking at the maze?
    • How did your group’s debugging process change once you could see exactly which step failed?
    • What is the minimum number of instructions needed to solve your maze? How do you know you cannot do better than this minimum?
    • How is this activity similar to, or different from, writing a program for a real robot? What are some of the challenges of programming a real robot that you did not encounter in this activity?