ULTIMATE Reeborg!

Overview
You'll learn two final pieces of Python decision-making — elif and not —
and use them to solve the Step 17 maze.
Builds on
Reeborg, the REEBORGANING!. Keep your saved programs from that lab.
Before you start
The mission below has a button that loads the world. Save your work — you'll turn it in at the end.
You've got it when…
- Reeborg reaches the goal and stops across several Step 17 runs with different starts and goals.
- Your solution uses a
whileloop withnot, andif/elif/else. - You've saved your
.pyfile. - You've saved
library.pyif your program imports it.
Collaboration & AI
Work: On your own. You can compare notes with a neighbor, but write your own commands.
AI — AIAS Level 1, No AI: Write and debug your own code without AI assistance. What the levels mean.
if/elif/else
-
Read the example and trace which statements run.
We have seen how
ifandelsework together. Let's add one more piece: "else if", writtenelif, works like this. The weather, activity, and milk functions below are illustrative placeholders, not Reeborg commands:
not
-
Read the example and trace which statements run.
Sometimes we want to ask if something is not true. The Python
notkeyword works like this:notcan also be used in awhileloop:
Your Mission
-
Write and test your maze solution.
Help Reeborg solve the maze, regardless of where it starts or where the goal is!
You must use a
whileloop with anot, andif/elif/else. Here's how:- while Reeborg is not at the goal:
- if the way is clear to the right, turn right and move forward
- else, if the way is clear to the front, move forward
- else turn left
Wall following
This strategy is called wall following. Test it in the assigned Step 17 world; it is not guaranteed to solve every possible maze. If Reeborg circles an open area without reaching a wall, first move until it reaches a wall, then begin the right-hand rule. Check for the goal during that initial movement too.
- while Reeborg is not at the goal:
Check Your Work
- Reset and run Step 17 several times to test different starting positions and goals. Check that Reeborg reaches the goal and stops. Save
Step 17.pyandlibrary.pyif your program imports it.
Turn It In
- Submit these Python source files:
-
Step 17.py -
library.py, if imported by your program
Include your library
Save the contents of the library tab separately from Python Code. When reopening your work in Reeborg, restore that code to the library tab before running a program that imports it.
How It's Graded
One score, from 0–4, covers your submitted Python source files.
| Score | Evidence |
|---|---|
| 4 Excellent | The maze program and any imported library are submitted. The solution uses while not and if/elif/else, reaches the goal, and stops. |
| 3 Above Average | All required programs work and use the required constructs, with minor errors or omissions in code organization. |
| 2 Average | Some required work functions, but a mission, required construct, or source file is missing. |
| 1 Below Average | Programs are largely incomplete or nonfunctional. |
| 0 Failing | No submission or no evidence of the required work. |
Credit: Adapted from Dan Schellenberg's Computer Science 20 textbook.