Skip to content

Unstable-Kernel/swarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

swarm

Collective behavior systems for the Unstable Kernel ecosystem. Implements flocking, predator-prey dynamics, and swarm coordination algorithms.

Architecture

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
Loading

Modules

Module Purpose
boids Reynolds flocking with configurable weights and radii
predator Pursuit/flee forces, kill ring mechanics, energy parameters

Boids Algorithm

Each agent computes three forces from its local neighborhood:

  1. Separation - steer away from agents within separation_radius
  2. Alignment - match average heading of neighbors
  3. Cohesion - steer toward center of mass of neighbors

The weighted sum is clamped to max_force.

Predator-Prey

  • Predators pursue nearest prey with configurable force
  • Prey flee from predators within flee_radius
  • Kill ring: prey within kill_radius of a predator are neutralized
  • Cooldown prevents rapid consecutive kills

Usage

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);

License

MIT

About

Collective behavior systems -- flocking, predator-prey, and swarm coordination algorithms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages