Skip to content

nishantHolla/flock-together

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Flock Together

This repository contains a Boids Flocking Simulator implemented in Javascript using P5JS.
It simulates the emergent behavior of flocking, inspired by Craig Reynolds' original Boids model (1986), and scales efficiently to large flock sizes by using a QuadTree data structure for spatial partitioning.
Without optimization, each boid checks all others to compute flocking forces (O(n²)), which becomes costly for large flocks. With the QuadTree, neighborhood searches are reduced to local regions, making the simulation much faster even with thousands of boids.

Flocking simulator: https://nishantholla.github.io/flock-together/flock-together/

Quad Tree visualizer: https://nishantholla.github.io/flock-together/quad-tree/

Boids model

Each agent updates its velocity based on three steering rules:

  • Separation: Avoid crowding neighbors.
  • Alignment: Align heading with nearby flockmates.
  • Cohesion: Move toward the average position of neighbors.

QuadTree

Instead of brute-force searching all boids, we insert all boids into a QuadTree each frame. When computing neighbors, each boid queries only its local region, dramatically reducing computations.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published