This project has been created as part of the 42 curriculum by lvasconc.
Fly-In is a drone network visualization and routing simulator. It loads a text-based map that defines hubs, connections, capacities, zones, and a drone fleet size. The application computes valid flight itineraries, enforces hub capacity and per-connection link limits, and renders the resulting network and drone movement in a Pygame window.
The goal is to help users understand graph navigation, constrained pathfinding, and visualization of network routing under capacity and zone constraints.
- Python 3.13+
- Dependencies installed from
pyproject.toml - Pygame asset files must be available in the
assets/directory
- Activate your virtual environment if you have one.
- Install dependencies with:
python -m pip install -r requirements.txtIf a requirements.txt file is not available, install using the project dependencies directly from pyproject.toml:
python -m pip install flake8 mypy networkx pydantic pygameRun the visualizer from the repository root:
python src/main.pyTo choose a different map file:
python src/main.py --map maps/easy/01_linear_path.txt- The first run may create or update
movement_log.txtin the project root. - If image assets are missing, the simulator falls back to a procedural background and drone sprite.
The project uses a custom parser to read map files and build the simulation configuration. The parser handles:
nb_dronesdeclarationstart_hubandend_hub- regular
hubdefinitions connectiondefinitions with optionalmax_link_capacityattributes, defaulting to1when omitted
Validation ensures the map is well-formed and rejects mutual bidirectional connection definitions. The parser also populates hub wall configuration based on the connection graph.
Data structures are defined using pydantic models for strict validation and type safety:
Hub: represents a node with coordinates, walls, zone type, color, and capacityConnection: represents a link between hubs with amax_link_capacityvalue, defaulting to1if omittedConfigs: aggregates hubs, connections, start/end definitions, and drone count
The simulator computes drone itineraries using a custom min-cost route generation strategy:
- Builds an adjacency structure from the hub graph
- Applies zone-based costs for restricted and priority areas
- Generates exactly
nb_dronesitineraries while respecting defined capacities and link capacities - Skips hubs with zero capacity to avoid impossible routes
This approach maintains control over path costs and avoids external dependency complexity for the pathfinder.
Drone movement is performed with step-based interpolation:
- Drones are activated sequentially
- Each drone moves from hub to hub along its itinerary
- Straight connections use linear interpolation
- Non-adjacent portal links use curved Bézier movement
- Hub occupancy is tracked to enforce capacity constraints
- Edge occupancy is checked against connection
max_link_capacity, so only the allowed number of drones can occupy a connection at once
When a drone reaches a restricted zone, the simulator logs a specific formatted movement string and applies a higher cost.
The Pygame visualizer is designed to enhance user experience through:
- Distinct hub coloring and zone indicators
- Straight lines for adjacent connections and curved paths for longer portal links
- Animated drone movement with rotation aligned to travel direction
- A heads-up overlay showing system status and controls
- A fallback background and sprite rendering when assets are missing
These features make the simulation easier to understand and provide immediate visual feedback on path selection, restricted zones, and active drone traffic.
- Python documentation: https://docs.python.org/3/
- Pygame documentation: https://www.pygame.org/docs/
- Pydantic documentation: https://docs.pydantic.dev/
- Graph algorithms overview: https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)
AI was used to assist with:
- Code organization and package refactoring
- Writing and refining documentation and comments
- Creating clearer module names and import structure
- Improving readability while preserving functionality
No AI was used for core algorithm logic design; the routing and visualization implementation was written and verified manually.
- The project is designed to be extensible: the parser, simulation, and rendering layers are separated into distinct modules.
- The
pyproject.tomlfile includes packaging metadata for thefly_inpackage located undersrc/.