Voxel Projection
A 3D lattice projection: each agent in the context occupies an integer-coordinate Voxel. The grid has fixed columns, rows, and layers; voxels are addressed by (col, row, layer) with col ∈ [0, columns), row ∈ [0, rows), layer ∈ [0, layers). The 3D analog of GridProjection.
Occupancy semantics:
VoxelOccupancy.MULTIPLE (default) — multiple agents may share a voxel. Typical for swarm / flock / drone models with low altitude separation.
VoxelOccupancy.SINGLE — at most one agent per voxel. placeAt throws if the target voxel is already occupied by a different agent; use tryPlaceAt for the conditional case. Useful for warehouse-style storage models where each slot holds one item.
Boundary semantics:
Bounded (default) — coordinates outside the bounds throw.
Torus (
torus = true) — coordinates wrap on all three axes. (A "ground+ceiling" model — wrap horizontally only, hard boundary vertically — should keeptorus = falseand clamp the vertical axis in the user's motion code.)
Spatial queries — neighborsOf, agentsAt, voxelsWithin — do linear scans over the occupancy map. Performance is fine for typical agent counts; for sphere-shaped continuous neighbor queries against many agents, use ContinuousVolume which has a spatial-hash index.
Constructors
Types
Mutable global defaults for VoxelProjection queries.
Functions
All agents currently in voxels within radius of voxel under metric. Excludes occupants of voxel itself unless includeCenter is true.
The 26 voxels in the Moore-26 neighborhood (Chebyshev3D distance 1) around voxel. If includeSelf is true, voxel is included (27 total).
Called by the AgentModel.Context when agent leaves. Default no-op — projections that track per-agent state (positions, edges) typically override to drop their bookkeeping for the departing agent.
Conditional placement for single-occupancy grids: returns true if the voxel was free (or already held this agent) and the placement succeeded; false if the voxel was occupied by another agent. Always succeeds for multi-occupancy grids.
The 6 voxels in the Von-Neumann-6 neighborhood (Manhattan3D distance 1) around voxel. If includeSelf is true, voxel is included (7 total).
All voxels within radius of voxel under the given metric. Excludes voxel itself unless includeSelf is true. Voxels outside the bounds are dropped for non-torus grids.