Skip to main content

Module flowfield

Module flowfield 

Source
Expand description

Flow field pathfinding and Reynolds flocking for large groups of agents.

Flow fields compute a single vector-field over a grid from one or more goal cells. Every agent in the group samples the field at its position and follows the resulting direction — O(1) per agent after the O(N) build.

§Example

use proof_engine::ai::flowfield::{FlowField, FlowFieldGroup};
use glam::Vec2;

let mut field = FlowField::new(20, 20, 1.0);
field.set_cost(10, 10, f32::INFINITY); // obstacle
field.build_integration_field(&[(19, 19)]);
field.build_direction_field();

let dir = field.get_direction(Vec2::new(0.5, 0.5));
println!("flow direction: {:?}", dir);

Structs§

Boid
An individual boid in the flock.
DynamicObstacleField
Applies temporary cost increases to a flow field (e.g., for dynamic obstacles).
Flock
Reynolds flocking simulation (separation, alignment, cohesion).
FlowField
A grid-based flow field.
FlowFieldAgent
A group of agents that share a single flow field to a common destination.
FlowFieldCache
Caches pre-built flow fields keyed by goal cell. Evicts least-recently-used entries when the capacity limit is reached.
FlowFieldGroup
Manages a group of agents all moving toward the same destination via a shared flow field.