Flocking Autonomous Agents


Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content
Next: Steering strategy

The source code of this playground is available on Github.

What's this about?

This playground exists to showcase a type of Swarm Intelligence known as Flocking.

Flocking is a decision-making technique for the movement of Autonomous Agents with limited visibility.

Autonomous Agents are entities in a program that make their own choices based on what they can perceive of a given environment. Here, we will be focusing entirely on how they decide to move.

What's the point?

This type of algorithm is intended to simulate life-like behaviour by focusing on how simple individuals behave in a group. Complex yet organised behaviours can be simulated such as a flock of migrating ducks, a school of fish navigating a coral reef, an intrusion of cockroaches searching for food or even a mob of bikers travelling down route 66.

Each individual shares the same environment and must obey the same core rules in order to display collective behaviour. However, variations from one individual to the next can be introduced for extra realism. The goal is to end up with a ruleset for which certain contraints guarantees non-still and non-chaotic visuals.

In our example, will will be defining rules for the movement of little creatures called boids.

What will I learn?

Take a look for yourself (press Run).


Each boid behaves identically, subject to a very simple steering mechanism governed by a set of forces called rules. Try pressing the Randomize ruleset button to change the weights of each force.


  • The basics of JavaScript. All the code here is designed to run directly in the browser.
  • An understanding of vectors and how to manipulate them to simulate basic physics. Here, the Victor.js library was used.
  • A healthy curiosity.
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content