All examples By author By category About


Flocking IV


This example is an implementation of a simple flocking algorithm that uses the dynamics of repulsion, attraction, and orientation zones. This example is based off of the algorithm described by Couzin.

The basic principle is that each agent has three regions in a growing radius around it: a zone of repulsion, a zone of orientation, and a zone of attraction respectively. By editing the sizes of these zones you can expect to experience different behaviour.

This example allows you to see the behavior when two types of agents are used, allowing you to specify parameters for each group.


There are two basic types of parameters used: initial conditions and agent parameters. Agent parameters can be updated any time, including while in play. Initial conditions however require a reset before they take effect.

Note: If an initial condition is changed then the Reset button will turn yellow, indicating that a reset is required before some changes take effect.

Initial Conditions:

Agent Parameters:

Color Key:


Dragging/Zooming behavior forked from mbostock's block: Drag & Zoom II

forked from lwthatcher's block: Directional Forces

forked from lwthatcher's block: Flocking

forked from lwthatcher's block: Flocking II

forked from lwthatcher's block: Flocking III

forked from lwthatcher's block: Flocking IV