fly-in 63 commits
10-08-2026

readme

359 lines 16 kB

This project has been created as part of the 42 curriculum by mleitao.

Description

Fly-in routes a fleet of drones from a start zone to an end zone across a graph of zones, in the fewest possible simulation turns.

Every zone holds a limited number of drones, every connection carries a limited number at once, some zones cost two turns to enter, and some may not be entered at all. Drones move simultaneously, so the hard part is deciding who waits, who goes, and along which route, so that the last drone lands as early as possible.

The program parses a map, solves it, re-checks the solution against the rules, and shows the run both as text and as a pixel-art animation.

Instructions

Build

CommandDescription
make, make installCreate the venv and install dependencies
make run MAP=map_fileSolve the map_file and render the solution in the terminal
make visual MAP=map_fileSolve the map_file and render the solution using pygame
make debug MAP=map_fileStart up the debugger with map_file
make lintRun flake8 and mypy with mandatory flags
make lint-strictRun flake8 and mypy with --strict flag
make cleanRemove Python caches
make fcleanRemove Python caches and the venv
make testRun the test suite with pytest

Directly, without make:

python -m src <map_file> [--visual] [--no-color]

A bad map prints one line naming the offending line and its cause, then exits with status 1. Nothing ever raises a traceback at the user.

$ python -m src broken.txt
error: line 7: max_drones must be positive, got 0
   hub: roof1 3 4 [max_drones=0]

Algorithm choices

The problem is flow, not shortest path

Shortest-path search cannot express the three things that decide the answer:

  • waiting, which is not a property of a path;
  • capacity over time, since a zone that is full now may be free later;
  • undoing a choice, when a route committed to early turns out to block a better one.

So the map is modelled as a maximum-flow problem instead. Each drone is one unit of flow, each zone's occupancy limit is an arc capacity, and each connection's limit is another. Max-flow's residual arcs are what allow an earlier decision to be taken back, which is why the result is optimal.

Building time into the map

Flow on its own has no clock. It can say how many drones fit through the map at once, but not when any of them gets anywhere.

The fix is to stop solving the map and start solving a stack of copies of it, one copy per turn - a time-expanded network. The bottom copy is the map at turn one, the next is the same map at turn two, and so on. A drone only steps from one copy up to the next. Moving one step up the stack is what "a turn passing" means.

Once time is a direction you travel in, the rules stop needing special handling and become properties of the stack:

  • Occupancy. Each copy of a zone has a doorway wide enough for its max_drones, and every drone standing there this turn has to fit through it. A drone that leaves during the turn is already on its way up to the next copy, so it is not standing in this one - which is the rule that a departure frees room for an arrival on the same turn.
  • Link capacity. Each copy of a connection has its own gate, shared by traffic in both directions, wide enough for its max_link_capacity. Being per copy, the limit applies per turn.
  • Waiting. Every zone in one copy is joined to itself in the next, so standing still is another way to move up the stack. Any plan the solver produces may include drones holding position.
  • Restricted zones. Reaching one costs an extra turn, so the route into it passes through a resting place of its own between two copies - that is the drone hanging on the connection, which is what prints as D1-corridor-tunnel. That resting place has exactly one way onward, into the restricted zone on the following turn. A drone therefore cannot loiter on a connection waiting for room, and the room it will need is claimed at the moment it sets off.
  • Start and end. All the drones are released into the start zone in the first copy. The end zone is an exit in every copy, so a drone may arrive on any turn, and once it does it leaves the picture.
  • Blocked zones are never built into any copy, along with the connections that touch them. Nothing has to remember to avoid them.

The neat part is what happens to the cost of a move. There is no number anywhere saying a restricted zone costs two turns - the cost is how far up the stack the move lands you. An ordinary move puts you in the next copy; a restricted one puts you two copies up. So every step through the stack is worth the same, the search never has to compare weights.

Growing one turn at a time

Nobody knows in advance how tall the stack needs to be. The stack starts one copy tall and grows a copy at a time, solved again after each one, until the number of drones that reach the end zone equals the number the map started with. That height is the answer.

It is also the smallest possible height. Adding a copy only opens new room, never takes any away, so if the fleet could have finished in fewer turns, the shorter stack would already have carried all of them when it was tried. It carried fewer, so no shorter run exists.

The same property is what makes growing cheap. Flow already pushed stays valid when a copy is added, so each fresh solve only looks for the routes the new turn opened rather than starting over. The repeated work is the search itself, not the pushing.

Two things stop a map that cannot be flown. Before any copies are built, a breadth-first search checks the end zone is reachable at all, so a map with its exit walled off says so immediately instead of after a hundred fruitless copies. And the growth loop carries a generous ceiling on the number of copies, so a map that is reachable but too tight to pass the whole fleet ends with a clear message rather than growing forever.

Dinic's algorithm

No graph library is used; src/flow/flow_network.py implements Dinic's algorithm over integer capacities and knows nothing about zones, drones or turns.

Arcs live in one flat list, added in pairs, so the reverse of arc e is e ^ 1. Pushing flow forward adds to the reverse arc, so the reverse arc's capacity is the load on the forward one, and no separate flow array is needed.

Each round labels nodes by hop distance with BFS, then pushes a blocking flow along arcs that descend exactly one level. A per-node cursor means each arc is examined once per phase. The walk is iterative: a time-expanded network is deep enough that a recursive descent would risk the interpreter's stack.

The solver is incremental - nodes and arcs may be added between calls and the next call resumes from the residual capacities left behind. That is what makes growing the horizon cheap.

Priority zones

A priority zone costs the same turn as a normal one, so it cannot change the minimum turn count - it can only decide which of the equally short runs comes out. Arcs toward priority zones are inserted first, and movement arcs before wait arcs, so the blocking flow tries them first. It is a tie-break.

The solver is not trusted

src/simulation.py replays the finished schedule and re-derives every rule from the map alone - adjacency, blocked zones, occupancy, link capacity, the two-turn entry, the ban on lingering in flight, delivery of every drone. It imports nothing from src/flow/.

A turn is checked in full before it is shown, so an illegal schedule can never reach standard output. Its errors read internal: because they blame the program, not the map.

Visual representation

Two views run at once. The text view prints the graded lines; the graphical view draws the same run in a window. A small Broadcast renderer forwards each turn to both, so the simulator keeps handing its turns to exactly one renderer.

Text

One line per turn, D<ID>-<zone>, or D<ID>-<connection> while a drone is in flight toward a restricted zone. Drones that do not move are omitted. Each drone's entry is colored from the destination zone's color= metadata, and color is dropped automatically when output is not a terminal, so piping the run to a file leaves the format untouched. --no-color forces it off.

Graphical

Run with --visual. The whole scene is drawn at 640×360 and scaled up by a whole number with nearest-neighbour sampling, which is what gives it the pixel-art look.

  • Generated terrain. The grass is speckled noise seeded from the map's zone names, so a map always looks the same and never repeats. Connections are worn dirt paths whose width grows with max_link_capacity - a wider road carries more traffic. Ground is drawn once and blitted whole.
  • Fixed palette. Every color on screen comes from one table, split into muted terrain slots and bright zone slots, so a map full of arbitrary color words still reads as one picture. A color= value the palette does not know is spread deterministically over neutral slots.
  • Zones are filled with their map color and outlined by type: a pale ring for priority, a dashed ring for restricted, a heap of stones for blocked. Labels show the name and, when a limit applies, how full the zone is.
  • Drones are sprites, area-downscaled from the source artwork and snapped back to the palette, with a thin outline so a near-black drawing stays visible against grass. Rotors alternate between two frames. A lone drone sits centred on its zone or on its path; a crowd arranges itself north, east, west, south, and a +n counter reports any that are standing still beyond four; a drone in transit is always drawn. A drone reaching the end zone explodes over two frames and disappears; the effect keeps its own clock, so a delivery on the final turn still plays out in full.
  • Labels are written at the window's own resolution, since a font drawn at eleven pixels loses the strokes that tell letters apart. On maps of more than twenty zones they start hidden.

Controls, always shown along the bottom:

keyaction
SPACEpause / resume
RIGHTfinish this turn, then pause
+ / -faster / slower
Lshow or hide labels
F, F11fullscreen
Q, ESCclose the window; the run keeps printing

Missing artwork, a missing font, or no display attached are all handled: the view falls back to drawn shapes, drops the labels, or reports one clear line. None of them crashes the program.

Example

maps/easy/02_simple_fork.txt:

# Easy Level 2: Simple fork with two paths
nb_drones: 4

start_hub: start 0 0 [color=green]
hub: junction 1 0 [color=yellow max_drones=2]
hub: path_a 2 1 [color=blue]
hub: path_b 2 -1 [color=blue]
end_hub: goal 3 0 [color=red]

connection: start-junction [max_link_capacity=2]
connection: junction-path_a
connection: junction-path_b
connection: path_a-goal
connection: path_b-goal
$ make run MAP=maps/easy/02_simple_fork.txt
D1-junction D2-junction
D1-path_a D2-path_b D3-junction D4-junction
D1-goal D2-goal D3-path_a D4-path_b
D3-goal D4-goal

Four turns. junction holds two drones and the link into it carries two, so the fleet crosses in two waves of two, splitting across both branches. No shorter run exists.

Performance

The score is the number of turns, so fewer is better. The target is the threshold the subject sets for each map.

mapdronestargetturns
easy/01_linear_path2≤ 64
easy/02_simple_fork4≤ 84
easy/03_basic_capacity4≤ 64
medium/01_dead_end_trap5≤ 128
medium/02_circular_loop6≤ 1510
medium/03_priority_puzzle5≤ 126
hard/01_maze_nightmare8≤ 3013
hard/02_capacity_hell12≤ 3516
hard/03_ultimate_challenge15≤ 4526
challenger/01_the_impossible_dream254543

Project layout

src/
  __main__.py  cli.py  errors.py
  zone.py  connection.py  network.py     domain objects
  parser.py  scenario.py                 map file -> scenario
  flow/
    flow_network.py                      Dinic, no domain knowledge
    time_expanded.py                     map -> layered network
    scheduler.py                         grow, solve, decode
  schedule.py                            the plan, shared by both halves
  simulation.py                          independent rule check
  render/
    base.py  text.py                     interface, terminal views
    palette.py  layout.py                pure helpers, no pygame
    pygame_view.py                       the window
assets/                                  drone and explosion artwork
maps/                                    test maps
tests/                                   pytest suite

Resources

Wikipedia

Videos

Articles

LLM Usage

Claude Code was used throughout, as a design partner and as a drafting tool. Concretely:

  • Architecture. The decision to model the problem as a time-expanded max-flow rather than repeated shortest-path search came out of a discussion with it, including the argument for why Dijkstra answers the wrong question here and the trade-off in code complexity that the choice buys.
  • Drafting. Module contents were drafted with it - the parser, the Dinic implementation, the time-expanded builder, the scheduler, the simulator and both renderers - then read, corrected and typed in by hand. Several of its suggestions were rejected or reworked, and the bugs introduced during that process were found by running the code and reading the failures.
  • Visual design. The pixel-art approach - internal resolution with integer upscaling, a constrained palette, deriving small sprites by area-averaging then snapping to the palette, and drawing text at window resolution - was worked out with it iteratively, against rendered screenshots.

Every design decision was reviewed before being accepted, and the code was verified with make lint, make lint-strict and the test suite.

  1*This project has been created as part of the 42 curriculum by mleitao.*
  2
  3# Description
  4
  5Fly-in routes a fleet of drones from a start zone to an end zone across a
  6graph of zones, in the fewest possible simulation turns.
  7
  8Every zone holds a limited number of drones, every connection carries a
  9limited number at once, some zones cost two turns to enter, and some may
 10not be entered at all. Drones move simultaneously, so the hard part is
 11deciding who waits, who goes, and along which route, so that the last
 12drone lands as early as possible.
 13
 14The program parses a map, solves it, re-checks the solution against the
 15rules, and shows the run both as text and as a pixel-art animation.
 16
 17# Instructions
 18
 19### Build
 20
 21Command | Description
 22--|--
 23`make`, `make install` | Create the venv and install dependencies
 24`make run MAP=map_file` | Solve the `map_file` and render the solution in the terminal
 25`make visual MAP=map_file` | Solve the `map_file` and render the solution using `pygame`
 26`make debug MAP=map_file` | Start up the debugger with `map_file`
 27`make lint` | Run `flake8` and `mypy` with mandatory flags
 28`make lint-strict` | Run `flake8` and `mypy` with `--strict` flag
 29`make clean` | Remove Python caches
 30`make fclean` | Remove Python caches and the venv
 31`make test` | Run the test suite with `pytest`
 32
 33Directly, without `make`:
 34
 35```bash
 36python -m src <map_file> [--visual] [--no-color]
 37```
 38
 39A bad map prints one line naming the offending line and its cause, then
 40exits with status 1. Nothing ever raises a traceback at the user.
 41
 42```
 43$ python -m src broken.txt
 44error: line 7: max_drones must be positive, got 0
 45   hub: roof1 3 4 [max_drones=0]
 46```
 47
 48# Algorithm choices
 49
 50### The problem is flow, not shortest path
 51
 52Shortest-path search cannot express the three things that decide
 53the answer:
 54
 55- **waiting**, which is not a property of a path;
 56- **capacity over time**, since a zone that is full now may be free
 57  later;
 58- **undoing a choice**, when a route committed to early turns out to
 59  block a better one.
 60
 61So the map is modelled as a **maximum-flow problem** instead. Each drone
 62is one unit of flow, each zone's occupancy limit is an arc capacity, and
 63each connection's limit is another. Max-flow's residual arcs are what
 64allow an earlier decision to be taken back, which is why the result is
 65optimal.
 66
 67### Building time into the map
 68
 69Flow on its own has no clock. It can say how many drones fit through the
 70map at once, but not when any of them gets anywhere.
 71
 72The fix is to stop solving the map and start solving a **stack of copies
 73of it**, one copy per turn - a time-expanded network. The bottom copy
 74is the map at turn one, the next is the same map at turn two, and so
 75on. A drone only steps from one copy up to the next. Moving one step
 76up the stack is what "a turn passing" means.
 77
 78Once time is a direction you travel in, the rules stop needing special
 79handling and become properties of the stack:
 80
 81- **Occupancy.** Each copy of a zone has a doorway wide enough for its
 82  `max_drones`, and every drone standing there this turn has to fit
 83  through it. A drone that leaves during the turn is already on its way
 84  up to the next copy, so it is not standing in this one - which is
 85  the rule that a departure frees room for an arrival on the same turn.
 86- **Link capacity.** Each copy of a connection has its own gate, shared by
 87  traffic in both directions, wide enough for its `max_link_capacity`.
 88  Being per copy, the limit applies per turn.
 89- **Waiting.** Every zone in one copy is joined to itself in the next, so
 90  standing still is another way to move up the stack. Any plan the
 91  solver produces may include drones holding position.
 92- **Restricted zones.** Reaching one costs an extra turn, so the route
 93  into it passes through a resting place of its own between two copies -
 94  that is the drone hanging on the connection, which is what prints as
 95  `D1-corridor-tunnel`. That resting place has exactly one way onward,
 96  into the restricted zone on the following turn. A drone therefore
 97  cannot loiter on a connection waiting for room, and the room it will
 98  need is claimed at the moment it sets off.
 99- **Start and end.** All the drones are released into the start zone in
100  the first copy. The end zone is an exit in every copy, so a drone may
101  arrive on any turn, and once it does it leaves the picture.
102- **Blocked zones** are never built into any copy, along with the
103  connections that touch them. Nothing has to remember to avoid them.
104
105The neat part is what happens to the cost of a move. There is no number
106anywhere saying a restricted zone costs two turns - the cost is how far
107up the stack the move lands you. An ordinary move puts you in the next
108copy; a restricted one puts you two copies up. So every step through the
109stack is worth the same, the search never has to compare weights.
110
111### Growing one turn at a time
112
113Nobody knows in advance how tall the stack needs to be. The stack starts
114one copy tall and grows a copy at a time, solved again after each one,
115until the number of drones that reach the end zone equals the number the
116map started with. That height is the answer.
117
118It is also the smallest possible height. Adding a copy only opens new
119room, never takes any away, so if the fleet could have finished in fewer
120turns, the shorter stack would already have carried all of them when it
121was tried. It carried fewer, so no shorter run exists.
122
123The same property is what makes growing cheap. Flow already pushed stays
124valid when a copy is added, so each fresh solve only looks for the routes
125the new turn opened rather than starting over. The repeated work is the
126search itself, not the pushing.
127
128Two things stop a map that cannot be flown. Before any copies are built,
129a breadth-first search checks the end zone is reachable at all, so a map
130with its exit walled off says so immediately instead of after a hundred
131fruitless copies. And the growth loop carries a generous ceiling on the
132number of copies, so a map that is reachable but too tight to pass the
133whole fleet ends with a clear message rather than growing forever.
134
135### Dinic's algorithm
136
137No graph library is used; `src/flow/flow_network.py` implements Dinic's
138algorithm over integer capacities and knows nothing about zones, drones
139or turns.
140
141Arcs live in one flat list, added in pairs, so the reverse of arc `e` is
142`e ^ 1`. Pushing flow forward adds to the reverse arc, so the reverse
143arc's capacity is the load on the forward one, and no separate flow
144array is needed.
145
146Each round labels nodes by hop distance with BFS, then pushes a blocking
147flow along arcs that descend exactly one level. A per-node cursor means
148each arc is examined once per phase. The walk is iterative: a
149time-expanded network is deep enough that a recursive descent would risk
150the interpreter's stack.
151
152The solver is **incremental** - nodes and arcs may be added between calls
153and the next call resumes from the residual capacities left behind. That
154is what makes growing the horizon cheap.
155
156### Priority zones
157
158A `priority` zone costs the same turn as a normal one, so it cannot
159change the minimum turn count - it can only decide which of the equally
160short runs comes out. Arcs toward priority zones are inserted first, and
161movement arcs before wait arcs, so the blocking flow tries them first.
162It is a tie-break.
163
164### The solver is not trusted
165
166`src/simulation.py` replays the finished schedule and re-derives every
167rule from the map alone - adjacency, blocked zones, occupancy, link
168capacity, the two-turn entry, the ban on lingering in flight, delivery of
169every drone. It imports nothing from `src/flow/`.
170
171A turn is checked in full before it is shown, so an illegal schedule can
172never reach standard output. Its errors read `internal:` because they
173blame the program, not the map.
174
175# Visual representation
176
177Two views run at once. The text view prints the graded lines; the
178graphical view draws the same run in a window. A small `Broadcast`
179renderer forwards each turn to both, so the simulator keeps handing its
180turns to exactly one renderer.
181
182### Text
183
184One line per turn, `D<ID>-<zone>`, or `D<ID>-<connection>` while a drone
185is in flight toward a restricted zone. Drones that do not move are
186omitted. Each drone's entry is colored from the destination zone's
187`color=` metadata, and
188color is dropped automatically when output is not a terminal, so piping
189the run to a file leaves the format untouched. `--no-color` forces it off.
190
191### Graphical
192
193Run with `--visual`. The whole scene is drawn at 640×360 and scaled up by
194a whole number with nearest-neighbour sampling, which is what gives it
195the pixel-art look.
196
197- **Generated terrain.** The grass is speckled noise seeded from the
198  map's zone names, so a map always looks the same and never repeats.
199  Connections are worn dirt paths whose width grows with
200  `max_link_capacity` - a wider road carries more traffic. Ground is
201  drawn once and blitted whole.
202- **Fixed palette.** Every color on screen comes from one table, split
203  into muted terrain slots and bright zone slots, so a map full of
204  arbitrary color words still reads as one picture. A `color=` value the
205  palette does not know is spread deterministically over neutral slots.
206- **Zones** are filled with their map color and outlined by type: a pale
207  ring for `priority`, a dashed ring for `restricted`, a heap of stones
208  for `blocked`. Labels show the name and, when a limit applies, how full
209  the zone is.
210- **Drones** are sprites, area-downscaled from the source artwork and
211  snapped back to the palette, with a thin outline so a near-black
212  drawing stays visible against grass. Rotors alternate between two
213  frames. A lone drone sits centred on its zone or on its path; a crowd
214  arranges itself north, east, west, south, and a `+n` counter reports
215  any that are standing still beyond four; a drone in transit is always
216  drawn. A drone reaching the end zone explodes over two frames
217  and disappears; the effect keeps its own clock, so a delivery on the
218  final turn still plays out in full.
219- **Labels** are written at the window's own resolution, since a font
220  drawn at eleven pixels loses the strokes that tell letters apart. On
221  maps of more than twenty zones they start hidden.
222
223Controls, always shown along the bottom:
224
225| key | action |
226|---|---|
227| `SPACE` | pause / resume |
228| `RIGHT` | finish this turn, then pause |
229| `+` / `-` | faster / slower |
230| `L` | show or hide labels |
231| `F`, `F11` | fullscreen |
232| `Q`, `ESC` | close the window; the run keeps printing |
233
234Missing artwork, a missing font, or no display attached are all handled:
235the view falls back to drawn shapes, drops the labels, or reports one
236clear line. None of them crashes the program.
237
238# Example
239
240`maps/easy/02_simple_fork.txt`:
241
242```
243# Easy Level 2: Simple fork with two paths
244nb_drones: 4
245
246start_hub: start 0 0 [color=green]
247hub: junction 1 0 [color=yellow max_drones=2]
248hub: path_a 2 1 [color=blue]
249hub: path_b 2 -1 [color=blue]
250end_hub: goal 3 0 [color=red]
251
252connection: start-junction [max_link_capacity=2]
253connection: junction-path_a
254connection: junction-path_b
255connection: path_a-goal
256connection: path_b-goal
257```
258
259```
260$ make run MAP=maps/easy/02_simple_fork.txt
261D1-junction D2-junction
262D1-path_a D2-path_b D3-junction D4-junction
263D1-goal D2-goal D3-path_a D4-path_b
264D3-goal D4-goal
265```
266
267Four turns. `junction` holds two drones and the link into it carries two,
268so the fleet crosses in two waves of two, splitting across both branches.
269No shorter run exists.
270
271# Performance
272
273The score is the number of turns, so fewer is better. The target is the
274threshold the subject sets for each map.
275
276| map | drones | target | turns |
277|---|---|---|---|
278| `easy/01_linear_path` | 2 | ≤ 6 | **4** |
279| `easy/02_simple_fork` | 4 | ≤ 8 | **4** |
280| `easy/03_basic_capacity` | 4 | ≤ 6 | **4** |
281| `medium/01_dead_end_trap` | 5 | ≤ 12 | **8** |
282| `medium/02_circular_loop` | 6 | ≤ 15 | **10** |
283| `medium/03_priority_puzzle` | 5 | ≤ 12 | **6** |
284| `hard/01_maze_nightmare` | 8 | ≤ 30 | **13** |
285| `hard/02_capacity_hell` | 12 | ≤ 35 | **16** |
286| `hard/03_ultimate_challenge` | 15 | ≤ 45 | **26** |
287| `challenger/01_the_impossible_dream` | 25 | 45 | **43** |
288
289# Project layout
290
291```
292src/
293  __main__.py  cli.py  errors.py
294  zone.py  connection.py  network.py     domain objects
295  parser.py  scenario.py                 map file -> scenario
296  flow/
297    flow_network.py                      Dinic, no domain knowledge
298    time_expanded.py                     map -> layered network
299    scheduler.py                         grow, solve, decode
300  schedule.py                            the plan, shared by both halves
301  simulation.py                          independent rule check
302  render/
303    base.py  text.py                     interface, terminal views
304    palette.py  layout.py                pure helpers, no pygame
305    pygame_view.py                       the window
306assets/                                  drone and explosion artwork
307maps/                                    test maps
308tests/                                   pytest suite
309```
310
311# Resources
312
313## Wikipedia
314
315- [Maximum flow problem](https://en.wikipedia.org/wiki/Maximum_flow_problem)
316- [Flow network](https://en.wikipedia.org/wiki/Flow_network)
317- [Ford–Fulkerson algorithm](https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm)
318- [Dinic's algorithm](https://en.wikipedia.org/wiki/Dinic%27s_algorithm)
319- [Max-flow min-cut theorem](https://en.wikipedia.org/wiki/Max-flow_min-cut_theorem)
320- [Breadth-first search](https://en.wikipedia.org/wiki/Breadth-first_search)
321- [Pixel art](https://en.wikipedia.org/wiki/Pixel_art)
322
323## Videos
324
325- WilliamFiset, [Max Flow Ford Fulkerson | Network Flow | Graph Theory](https://www.youtube.com/watch?v=LdOnanfc5TM)
326- WilliamFiset, [Dinic's Algorithm | Network Flow | Graph Theory](https://www.youtube.com/watch?v=M6cm8UeeziI)
327- WilliamFiset, [Dinic's Algorithm | Network Flow | Source Code](https://www.youtube.com/watch?v=_SdF4KK_dyM)
328
329## Articles
330
331- cp-algorithms, [Maximum flow - Dinic's algorithm](https://cp-algorithms.com/graph/dinic.html)
332- cp-algorithms, [Maximum flow - Ford-Fulkerson and Edmonds-Karp](https://cp-algorithms.com/graph/edmonds_karp.html)
333- TopCoder, [Edmonds-Karp and Dinic's Algorithms for Maximum Flow](https://www.topcoder.com/thrive/articles/edmonds-karp-and-dinics-algorithms-for-maximum-flow)
334- [pygame documentation](https://www.pygame.org/docs/).
335
336## LLM Usage
337
338Claude Code was used throughout, as a design partner and as
339a drafting tool. Concretely:
340
341- **Architecture.** The decision to model the problem as a time-expanded
342  max-flow rather than repeated shortest-path search came out of a
343  discussion with it, including the argument for why Dijkstra answers the
344  wrong question here and the trade-off in code complexity that the
345  choice buys.
346- **Drafting.** Module contents were drafted with it - the parser, the
347  Dinic implementation, the time-expanded builder, the scheduler, the
348  simulator and both renderers - then read, corrected and typed in by
349  hand. Several of its suggestions were rejected or reworked, and the
350  bugs introduced during that process were found by running the code
351  and reading the failures.
352- **Visual design.** The pixel-art approach - internal resolution with
353  integer upscaling, a constrained palette, deriving small sprites by
354  area-averaging then snapping to the palette, and drawing text at window
355  resolution - was worked out with it iteratively, against rendered
356  screenshots.
357
358Every design decision was reviewed before being accepted, and the code
359was verified with `make lint`, `make lint-strict` and the test suite.