Live at boids.dev
An interactive tool that allows users to experiment with settings on a group of boids, simulating the behavior of animals in flocks or swarms.
- Introduction
- Features
- Getting Started
- Usage
- Examples
- Technologies Used
- Inspiration
- Contributing
- License
This project implements a boid simulation, which models the flocking behavior of birds or other animals. Boids follow simple rules that, when combined, create complex and lifelike group movements.
- Real-time simulation of boid behavior
- Adjustable parameters:
- Number of boids
- Separation distance
- Visual range
- Speed limit
- Centering factor
- Matching factor
- Multiple color themes
- Tail visualization option
- Arrow visibility toggle
- Mouse interaction (on non-touch devices)
To run this project locally:
- Clone the repository
- Install dependencies with
npm install
- Start the development server with
npm run dev
The main simulation can be found in the App
component.
Key functions controlling boid behavior include:
keepWithinBounds
: Prevents boids from leaving the screenflyTowardsCenter
: Attracts boids to the center of nearby boidsavoidOthers
: Implements separation behaviormatchVelocity
: Aligns boid velocity with nearby boids
Users can interact with the simulation using various UI controls, including sliders and buttons.
- React
- TypeScript
- Vite
- HTML Canvas
This project was inspired by Craig Reynolds' paper on boids: Flocks, Herds, and Schools: A Distributed Behavioral Model