Computing · Investigate

Debug a paper robot

Where does an instruction sequence first stop matching its goal?

Give a paper robot a starting direction, trace its commands and repair one route. No coding software is needed.

15–25 minutes, or one trace for a first try. More time is optional.

A 4-by-4 board has an east-facing start at (1,1), a block at (2,2) and goal at (3,3). The first sequence stops before the block. The repaired route travels right twice, turns north, then moves up twice.
Exact example: locate the first blocked move. Open full-size diagram ↗

Start here

Draw a 4-by-4 grid. Columns run left to right and rows bottom to top, both 1 to 4. Put an east-facing arrow at (1,1), a goal at (3,3) and a block at (2,2).

Use your idea or the example below. Talk, write, draw, point or listen first. You can stop after one step.

Try it your way.

  1. Set the command language

    F means move one square in the direction the arrow faces. L means turn left 90 degrees on the same square; R means turn right 90 degrees on the same square. Turns do not move the robot. Stop before a move would enter the block or leave the grid.

  2. Trace the first program

    Try F, L, F, F, R, F from the stated start. Record the square and facing direction after each command. At the first blocked move, stop and mark that command instead of completing the rest.

  3. Make a repair

    Reset the arrow to (1,1), facing east. Try F, F, L, F, F, or design your own sequence. Record the trace again. Reaching the goal is useful information about this starting case.

  4. Explain the repair's limits

    Describe which instruction caused the original problem and why the replacement route avoids it. If you want another test, change the starting direction on paper and predict whether the same commands still work.

One possible version

Exact example: locate the first blocked move

This robot and its board are invented. East is right, north is up. The goal is (3,3); the robot begins at (1,1), facing east.

  • F, L, F…: move to (2,1) east; turn north at (2,1); the next F would enter blocked (2,2), so stop before it.
  • Repair F, F, L, F, F: (2,1) east → (3,1) east → (3,1) north → (3,2) north → (3,3) north.
  • The repair reaches this goal in five commands: four moves and one turn.

The repair is tested by tracing this one starting case. It is not a general route-finding algorithm, a real robot test or proof that every changed board will work.

A different way.

Use the supplied trace and point to the first problem, or have someone move the arrow exactly as you direct. A smaller empty grid is another valid starting point.

If you want more.

Write a repeat instruction for two forward moves and explain what it expands to. Test a different starting direction before claiming the shorter notation still reaches the goal.

Something to keep?

Did I check the robot's direction as well as its square?

You can keep a question, a sketch or a change of mind. A finished product is optional.

This opens an editable starter in your project tools. It asks before replacing open work. Choosing it does not save or share your work automatically.