Collective behavior systems for the Unstable Kernel ecosystem. Implements flocking, predator-prey dynamics, and swarm coordination algorithms.
graph TD
subgraph "kernel-swarm"
B[boids<br/>separation, alignment, cohesion]
P[predator<br/>pursuit, flee, kill ring]
end
B --> |steering force| AGENT[Agent Velocity]
P --> |pursuit/flee force| AGENT
| Module | Purpose |
|---|---|
boids |
Reynolds flocking with configurable weights and radii |
predator |
Pursuit/flee forces, kill ring mechanics, energy parameters |
Each agent computes three forces from its local neighborhood:
- Separation - steer away from agents within
separation_radius - Alignment - match average heading of neighbors
- Cohesion - steer toward center of mass of neighbors
The weighted sum is clamped to max_force.
- Predators pursue nearest prey with configurable force
- Prey flee from predators within
flee_radius - Kill ring: prey within
kill_radiusof a predator are neutralized - Cooldown prevents rapid consecutive kills
use kernel_swarm::boids::{boids_steer, BoidsParams};
use kernel_swarm::predator::{pursuit_force, flee_force};
// Flocking
let neighbors = vec![(10.0, 5.0), (-8.0, 3.0)];
let vels = vec![(1.0, 0.5), (-0.5, 1.0)];
let (fx, fy) = boids_steer(1.0, 0.0, &neighbors, &vels, &BoidsParams::default());
// Predator pursuit
let (px, py) = pursuit_force(20.0, 10.0, 0.05);MIT