🚀 Reeborg Maze
A beginner-friendly Python project that guides a robot through a maze in Reeborg's world by following the right wall, whatever its random start position and direction.
📚 Table of Contents
🧭 Overview
This is the final project of day 6 of Udemy's 100 Days of Code: The Complete Python Pro Bootcamp. The maze is fixed, but the robot starts at a random position and heading, so the program must work from anywhere.
The robot follows the right wall:
- Walk forward until a wall is hit, then turn left (this puts a wall on the right and avoids infinite loops).
- Until the goal is reached:
- if the right side is clear: turn right and move,
- else if the front is clear: move,
- else: turn left.
The project contains:
src/reeborg_maze/reeborg_script.py– the script to paste into Reeborg's world.src/reeborg_maze/maze_solver.py– the same algorithm as a testable function.src/reeborg_maze/simulator.py– a small offline simulator that reads Reeborg world JSON files.src/reeborg_maze/visualizer.py– draws the world as text and animates the robot.tests/– unit tests and three test worlds with different start headings.
📋 Requirements
- Python 3.13 or newer
- No runtime dependencies (pytest is installed as a dev dependency for the tests)
- Optional: Doxygen to build the API documentation
🛠️ Setup
Create and activate a local virtual environment, upgrade pip and install the project in editable mode.
Windows (PowerShell):
python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
Linux / macOS:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
▶️ Run
In Reeborg's world: open the maze link above, choose Python mode, paste the contents of src/reeborg_maze/reeborg_script.py into the editor and press run.
Offline, against a world file:
python -m reeborg_maze tests/worlds/problem_world.json
Watch the robot move in the terminal (optionally pick a start with X Y HEADING, where heading is 0=east, 1=north, 2=west, 3=south):
python -m reeborg_maze tests/worlds/problem_world.json --animate
python -m reeborg_maze tests/worlds/problem_world.json --animate --delay 0.05 --start 1 1 0
The robot is drawn as > ^ < v, the goal as G and mud as ~~~.
Build the documentation (written to docs/html):
doxygen Doxyfile
🧪 Tests
The tests use pytest; each world is solved from every free cell and all four headings.
python -m pytest -v
