This project has been created as part of the 42 curriculum by smikhail.
This project is an object-oriented drone routing and simulation system implemented in Python. The goal of this project is to navigate a fleet of drones through a complex network of zones (graph) from a starting hub to an ending hub in the minimum number of turns. The simulation enforces strict rules for movement, map parsing, zone capacities, link capacities, and varying movement costs based on the type of zones (e.g., normal, restricted, priority, blocked).
Installation & Dependencies:
The system is built using standard Python 3. You can verify typing and perform linting using flake8 and mypy.
You can install these dependencies with:
make installExecution: You can run the main simulation with a map file. Provide the path to the map text file as an argument.
make run
# or directly
python3 main.py <map_file.txt>Available Makefile Commands:
make install: Installsflake8andmypy.make run: Runs the program usingmain.pyand a default map.make debug: Runs the program withpdbfor debugging.make clean: Removes all caching directories.make lint/make lint-strict: Runs flake8 and mypy for static code analysis.make test: Runs a custom testing script for the project.
Classic references for graph traversal algorithms and object-oriented design were referenced during the development:
- Dijkstra's Algorithm Overview: Used for understanding optimal pathfinding on weighted graphs.
- Python Documentation: Typing and Object-Oriented best practices.
AI Usage: AI was utilized in the development of this project for:
- Assisting in debugging errors related to static typing (
mypy). - Refactoring the visualization components and refining the Python application logic to ensure adherence to best practices.
- Writing this exact
README.mddocumentation, to ensure all core project requirements are clearly met. - Perfecting the algorithms
- Writting all the codes for the colors that appear in the terminal
The Pathfinder component employs a static distance gradient (Flow Field) mechanism which elegantly resolves traffic naturally without extensive recomputation.
- Dijkstra's Algorithm Initialization: A reversed Dijkstra's algorithm computes the shortest paths from every node on the map to the ending hub exactly once at the beginning of the simulation. This ignores live traffic but considers base movement costs across standard, restricted, and priority zones.
- Turn-based Calculations: Each turn, drones are sorted by their static distance to the goal. Those closest to the goal move first. Drones check adjacent connected zones prioritizing movement towards lower distances while respecting capacities on target zones (
max_drones) and connections (max_link_capacity). Wait states are utilized if restricted zones involve multi-turn traversals. This guarantees progression toward the goal while strictly ensuring capacity restrictions.
The simulation includes a console-based visual output that actively enhances the user experience by clarifying complex drone movements in the text console:
- ANSI Terminal Styling: Detailed ANSI 256-color support is built into the
SimulationEngine. - Colored Zones Integration: Output logs colorize the tracking of drones as they traverse dynamically parsed zones based on specific colors assigned to nodes in the map configuration.
- Improved Output Reading: Utilizing colored text (e.g.,
ANSI_COLORS) directly relates a drone ID (D1-EndHub) to its logical zone progression and states natively in standard terminals without a secondary graphical interface. This allows quick debugging and monitoring of massive drone clusters without eye strain.