Natural Flocking
20 Oct 2019
Flocking behavior is the behavior exhibited when a group of birds, called a flock, are in flight.
In the canvas below I have tried to simulate the same with digital "Boids".
This is different from my earlier attempt at flocking wherein all the "boids" where in a flock. In this
attempt I ensured that "boids" only flock with members who are within range.
Sorry, your browser does not support Canvas.
| Variable | Value Range | Value |
| Align Radius | 50 - 150 | |
| Cohesion Radius | 50 - 200 | |
| Separation Radius | 1 - 50 | |
Now, I haven't done anything different with my flocking demo above than other flocking implementations elsewhere on the internet. The boids follow the same pattern that defines flocking behaviour. Remember, each boid is independent of others and has three rules to follow.
![]() |
Alignment: When in range of other boids, the boid will try to align itself with the other boids. This is done by finding the average speed of the other boids and normalize these averages. |
![]() |
Cohesion: When in range of other boids, the boid will try to move to the center of mass of the other boids. This is done by finding the average of their positions (and not their speed) and changing the boid speed to align with the average position. |
![]() |
Separation: This is the opposite of Cohesion. When boids get too close to each other. We want to avoid that just like the real world. This is done by finding the average of their positions (and not their speed) and changing the boid speed to move away from the average position. |
Javascript Demos ▼
Here's a bunch of javascript... things I wrote over the years whenever time permitted.
Abhivadaye Generator
Game of Life
Anagram Finder
Deflection Demo
Break Out
Cycloids
Double Pendulum
Flocking
Fog fly through
Fractals
EV Savings
Target Finder
Bouncing Spheres
Horizontal Stars
Image Scanning
Pandemic Simulator
JSON Beautify
Julia Sets
Kaleidoscope
Kock Fractals
Lorenz Attractor
Mandlebrot Set
Meta Balls
Number Convert
Number Game
Forces on Objects
Particles & Nodes
Simple Pendulum
Perlin Noise
Poisson Disk
QuadTree Search
8 Queens Problem
Natural Flocking
Ripples
Set Demonstration
Sine Waves
Classic Snake
Starfield
Sierpinski Triangles
Super Shapes 2D
Tic Tac Toe
Voronoi Diagram
Who Moved My...


