← Back to course
Python 11-12 / Week 06 / Mission Quest
6/6
Week 06 · Drive and Test

Mission Quest

Mission Quest: Drive the coin
// Step by step across the field, with tests at the edges
⏱ about 30 min

Saturday: Mission Quest: Drive the Coin

Comet sets last week's paper field on the table and drops a coin on row 0, column 0. "Meet paper Pip," she says. "Facing east."

Wren writes FFRFFF on a scrap of paper. "What does the evidence say before each step?" he asks. "Check the square ahead first. Rock or edge means blocked."

Nova hovers over the coin. "How can I help?" she asks. "Keep a log, just like the rover does. One line for every step."

Comet hands you the coin. "Lead programmer, you are the rover today. Your family writes the commands."

◇ DRIVE THE COIN
You need the paper field from last Saturday. If it is lost, draw it again: 5 rows by 6 columns, copied from the field map.
Put a coin on row 0, column 0. Draw a small arrow on a sticky note to show it faces east, and keep a battery count starting at 100.
Your partner writes a command string with F, L and R, like FFRFFF.
Follow it one letter at a time. Before each F, check the square ahead. If it is a rock or off the field, write blocked and do not move.
Each step you take uses 5 battery. Write moved to (row, col) in your log for every step.
Swap roles. Try to write a string that reaches a sample spot without being blocked.
For a grown-up
Your learner is acting out the rover code they wrote this week: check first, then move, then log.
Try writing a command string that runs into a rock or off the edge. A calm "blocked" is the right answer.
Ask them to compare the coin's log with the log their program prints for the same route.
  1. Check the cell ahead before moving: that is a bounds check.
  2. A blocked step is logged, and the rover stays put.
  3. Every step uses battery, and the log records every move.
WEEK 6 CHECK
  • Read the question.
  • Tap your answer.
Pip at (0, 0) faces E and runs FFRFX. Where does it end?
What does run() do with a letter it does not know?
What does test_fieldsim.py print when every test passes?
WHY THIS EXERCISEThe final print only runs after every assert has passed.

A big week: Pip drives, checks and logs, and your tests prove it. Next week the fleet arrives.

← Friday