Skip to main content

ECS boids simulation — free tier: Vec3 math + 3-force flocking

Project description

Boidswarm (zombiebubble-boids)

An advanced, high-performance Entity Component System (ECS) flocking simulation.

While traditional "Boids" algorithms simulate flocking using 3 basic rules (separation, alignment, cohesion), boidswarm introduces an advanced Graph-Laplacian Leader Election system. This allows your flock to intelligently pass messages, nominate leaders, and gracefully recover when leaders get stuck or destroyed.

Installation

pip install boidswarm

Features (No Advanced Math Required!)

Boids Animation

If you've never used Boids before, think of them as AI agents that group together like flocks of birds or schools of fish. This library makes managing them incredibly robust:

1. The "Ripple Effect" (Signal Propagation)

In basic flocking, a boid only reacts to its immediate neighbors. If a boid at the front spots the player or a target, the back of the flock won't know and might break formation.

  • How it works: Information (like a "pursuit signal") diffuses through the flock like heat spreading through metal.
  • How to use it: You control this with the alpha parameter.
    • alpha = 0.1 to 0.3: Highly recommended. The signal spreads fluidly and realistically.
    • alpha = 0.0: No spreading (traditional, dumb boids).
    • alpha = 1.0: Instant hive-mind transmission.

2. Auto-Healing Leader Election

Navigating complex environments usually causes flocks to get stuck in corners.

  • How it works: Beneath the hood, the system dynamically classifies every boid into 7 roles (e.g., Follower, Sub-Leader, Leader, Prime).
  • How to use it: It works automatically! If your current leader drops out of the simulation (becomes a "Phantom Dead") or its speed drops too low (becomes "Phantom Stuck"), the system immediately promotes a Sub-Leader to take its place. The flock never permanently breaks down.

3. Customizable Flock Personalities (Gram Matrix)

You can tune the underlying scoring engine to fit the specific needs of your game or simulation without rewriting any core logic:

  • Resilience-First: Best for massive, chaotic, or combat-heavy flocks. It guarantees the flock stays together even if multiple leaders are lost simultaneously.
  • Expressiveness-First: Best for small, tight-knit flocks where you want highly nuanced, synchronized, and agile movements.

Command Line Usage

Once installed, you can test the simulation via the CLI:

zombiebubble

Understanding the Console Output

When you run zombiebubble, it will simulate a flock of boids and print its metrics to your console. Here's what those numbers mean:

  • step / time: The current simulation frame and simulated time elapsed.
  • spread: How far apart the boids are spread out (in meters). A shrinking spread means the flock is gathering together (Cohesion).
  • avg speed: The average speed of the boids.
  • status: A quick text summary of what the flock is currently doing (e.g., "gathering", "compact flock").

At the end of the run, the tool looks at the initial vs. final spread. If the final spread is smaller, it mathematically confirms that the "Cohesion" rule successfully pulled the flock together.

License

Licensed under GPL-3.0-only.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boidswarm-0.1.4.tar.gz (289.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boidswarm-0.1.4-py3-none-any.whl (290.0 kB view details)

Uploaded Python 3

File details

Details for the file boidswarm-0.1.4.tar.gz.

File metadata

  • Download URL: boidswarm-0.1.4.tar.gz
  • Upload date:
  • Size: 289.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for boidswarm-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7664d5e58c338e7f4953bc5b8ce51a7912b4cfa54b6c373e21408792e0fec194
MD5 24887ab144650a8f33824c08d33f06b1
BLAKE2b-256 a980c8f087e8694026cb08a32293f20478f0a0b974ca755ee16de109b9f5ae6f

See more details on using hashes here.

File details

Details for the file boidswarm-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: boidswarm-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 290.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for boidswarm-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a0fd6949cf57231afaeaf9d777b042b5f840d892390d7130edc9706e418a48fa
MD5 31d6b6c3da45bfaddcc3fd910ab495e7
BLAKE2b-256 684f79b1518e9eab754410760b33df2d0017922521cd10472b4a19879d4c84aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page