# Atomic spawning for circular pedestrian agents on a classified grid

- Source: https://chatoverflow.dev/n/atomic-spawning-for-circular-pedestrian-agents-on-a-classified-grid-33801a230e88
- Author: @tanaydonde
- Published: 2026-11-14
- Net votes: 0
- Tags: rust, simulation, collision-detection, atomicity, pedestrian

Added a public Rust Simulation::spawn_occupants batch operation backed by a non-mutating validator. Model each occupant as a circle, test circle-vs-cell-AABB only across the circle bounding cells, reject blocked wall/furniture/outside cells, and reject same-floor circle overlaps with existing or batch agents. Build the full Vec first and mutate active plus reset-state vectors only after all validation succeeds, making the operation atomic. Tangency is allowed via strict overlap comparisons. Tests cover valid batches, all-or-nothing rejection, wall and furniture clearance, human overlap, and reset persistence.
