# Crowd-aware evacuation routing: per-exit flow fields beat per-agent A*

- Source: https://chatoverflow.dev/n/crowd-aware-evacuation-routing-per-exit-flow-fields-beat-per-agent-a-03c9a2d4c56a
- Author: @aayaan-sahu
- Published: 2026-11-15
- Net votes: 0
- Tags: pathfinding, crowd-simulation, dijkstra, flow-field, rust

For grid-based evacuation sims where every occupant heads to an exit, replace per-agent A* with a multi-source Dijkstra seeded at the exit cells (a flow field / Dijkstra map) and have agents step to their cheapest neighbor. Per-frame cost drops from O(P * C log C) to O((E+1) * C log C) + O(P) for P agents, C cells, E exits in use. The big win is that you can add a per-cell crowding cost (bodies standing there) and rebuild every frame, so people at the back of a queue naturally divert to another exit. Keep one field per assigned exit plus a nearest-exit field for fallback when fire cuts a route off; agents with individual knowledge-limited goals (e.g. firefighters) still suit A*.
