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

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.2.tar.gz (21.9 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.2-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: boidswarm-0.1.2.tar.gz
  • Upload date:
  • Size: 21.9 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.2.tar.gz
Algorithm Hash digest
SHA256 c34497dfbd835ed9aee9821d1d1b2ac30701a9e8f8946268b7e2712fac8af820
MD5 29579b3d158f41bbd86e6cc68f65e6e7
BLAKE2b-256 f6f8fda4c1d34fbfe45cff5a7446f68bb18a4a9f8dbadb8935ccd7d147be243a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: boidswarm-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 21.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 04dc41d622d71eed8948ee40b0c132c38265d0dfa69abeaa57857844618c2552
MD5 05d90a8fe3c003fdbdd9825487e578d7
BLAKE2b-256 70ddf304685ef774c0676efc79ecb09e8e51bbc602a38c9cfbe04038c00b1e55

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