Back
Close

Flocking Autonomous Agents

[CG]jupoulton
35.4K views
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).

Flocking

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.

Pre-requisites

  • 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.
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants