fly-in
Python project · graphs, pygame
Drone fleet routing: Dijkstra pathfinding, turn-based scheduling and a pygame replay.
- 16turns on capacity hell (target 35)
- 13on maze nightmare (target 30)
- 44on impossible dream (ref 45)
The problem
Move a fleet of drones from a start hub to an end hub in as few turns as possible, through zones with capacity limits, slow restricted zones and blocked ones.
What I built
- A parser for the custom map format with its own error types.
- Hand-rolled Dijkstra with costs by zone type (priority zones cost 0.9 so the heap prefers them without a tie-breaker).
- Several diverse lanes, found by re-running Dijkstra with a penalty on edges already used, then drones spread lem-in style so shorter lanes take more.
- A dry run of every possible split that keeps the fastest one, so using several paths can never be worse than one.
- A pygame replay with zoom, pan, stepping back and forth, and a frame-by-frame replay of Dijkstra itself. It also runs here in the browser, compiled to WebAssembly, with a map picker in front.
The hard part
My first engine was too generous. A drone could land in a restricted zone and leave it in the same turn, and a slot there was only taken on arrival, so two drones could claim it at once: that is how impossible dream came out at 39 turns. With one action per drone per turn and the slot reserved at departure, the honest count is 44 (reference 45), and circular loop went from 9 to 15, exactly its target. The lanes won turns back: every split of the fleet is dry-run and kept only if it finishes sooner, which took simple fork from 6 to 4.
Built with
- Python 3.10+
- heapq
- Pydantic v2
- pygame-ce
- mypy --strict
- pygbag / WebAssembly
More projects
- metro · Lisbon metro sim in pixel art: watch the four lines run, step into any station, board a train and ride it.
- pac-man · Pac-Man in Python, built as a duo with sylvzzz: a new maze every level and four ghosts that each hunt you differently.
- call_me_maybe · Turns a sentence into a JSON function call with a 0.6B model using constrained decoding — parseable by construction, not by luck.
- codexion · Multithreaded twist on the Dining Philosophers: coders compete for shared dongles, with FIFO/EDF scheduling.
- dbaltaza.pt · A game-console portfolio where every project is a pre-rendered disc: Vite + TypeScript, no framework, and a paint budget the tests measure.
- a-maze-ing · Maze generator with multiple algorithms, pathfinding solvers and terminal visualization.
- push_swap · Highly optimized sorting with two stacks and a tiny set of allowed operations.
- ft_printf · printf rebuilt from scratch: chars, strings, pointers, decimals, unsigned and hex.
- get_next_line · Reads a file descriptor one line at a time with careful dynamic memory handling.
- Libft · My own C standard library — the foundation every later 42 project is built on.