Qcomp — Grid routes — Practice example 1.1

Goal
Build a sequence of up to four commands, check the result and correct the route. The four tasks from the Mirasol project are straight, one-turn, two-turns and detour. This is a standalone software exercise.

Preparation
Use Python 3.10 or later. Unpack the ZIP and open a terminal in the extracted folder. The script uses the Python standard library and runs offline without an account or equipment.

First run
python robot_path.py --puzzle straight --program up up

Obstacle detour
python robot_path.py --puzzle detour --program down right right up

Run the automated checks
python -m unittest -v

Grid rules
The grid is 3 by 3. Rows and columns in the JSON start at zero. On the site, the displayed coordinates start at one. up decreases the row, down increases it, left decreases the column and right increases it. These directions refer to the grid.

Each run begins at start. A command that hits an obstacle or leaves the grid does not move the robot. The next command still runs. The program succeeds if its last cell is goal. More than one route can succeed. blockedCommands counts blocked moves.

Classroom activity
1. Choose a task in lessons.json and mark the start, goal and any obstacle on a paper grid.
2. Write a route with arrows and predict the cell reached after each command.
3. Run your program and compare the steps in the output with your prediction.
4. Find the first mismatch, change one command and run the route again from the start.
5. For one-turn, find another correct route. Compare a route with a blocked move and one without any.

Files
robot_path.py runs the route. lessons.json contains the four tasks and reference routes. test_robot_path.py checks the routes, grid boundaries, obstacle handling, restarts and invalid commands. manifest.json records the revision and SHA-256 hashes.

For a physical robot, agree on the coordinate system, controller, power supply, grid and lesson, then test them together on the selected kit.
