Skip to content

How to Simulate Flocking Behavior

How to Simulate Flocking Behavior In a virtual world

Overview:

Flocking Behavior is a type of social behavior that occurs when a group of individuals follow the same individual or each other. The term was first coined by English biologist and ornithologist, Dr. W. H. Thorpe in 1951 to describe the movement of birds in flight as they move as one unit without any apparent leader or hierarchy, often called “flock” or “school”. The term has been used to describe humans and animals that behave similarly – following one another without an apparent leader or hierarchy.

The boids model is a popular algorithm used to simulate flocking behavior. The algorithm is based on three simple rules which describe how birds flock or fish school. In this article, we will go through these simple rules and how they can be implemented to simulate flocking behavior.

Flocking Behavior

Flocking behavior is an example of group behaviour, which considers the movement of entities as a group to adjust individuals’ movement. This means that the individual entities do not have knowledge of the location and movements of all entities, but do perceive neighbouring individuals and follow some simple rules to adjust their own movements accordingly. This technique can create realistic swarming behaviour similar to the movement of flocks of flying birds or insects. In this project, flocking behaviour is applied when a group of agents move in the same direction to create a more natural group movement and simplify the path-finding process. A simple mathematical model of this behaviour is presented by three rules based on the Boids model [1]. These rules include separation, cohesion, and alignment, the effects of which are illustrated in the Figure below:

The flocking behaviour rules in action [1]

According to the Separation rule, each individual avoids collisions with its neighbours by adjusting its position. The cohesion rule helps the individuals to remain close to their neighbours by staying near the average position of all of them.

Based on the Alignment rule each individual moves in the same direction as its neighbours. This is done by adjusting the direction in which an agent is heading to the average direction of its neighbours.

The useFlockingBehaviour() method of SteeringBehaviour class applies the forces required to activate flocking behaviour (as shown in the UML diagram in Figure below).

Flocking-behaviour rules can facilitate and simplify path planning by multiple agents when they are travelling as a group from A to B. Instead of finding the shortest path individually, agents that are travelling to the same target destination can form a team and apply the model to follow a leader agent to arrive at their destination. The path-finding procedure is performed by only one agent rather than several agents. This reduces processing workload and increases efficiency. The below figure demonstrates this behavior.

Agents following a lead agent using Flocking Behavior

In order to check whether a follower agent is blocked or lost, the leader agent calculates an estimate of the time required to traverse the path to reach the target and relays this to the follower agents. If a follower agent does not reach the destination within that time then it performs the path-finding algorithm by itself to find a different path.

Conclusion

Flocking behavior is a type of decentralized control algorithm used to generate realistic artificial flocking or herding behavior in computer animation and robotics. The algorithm is based on three simple rules which describe how birds flock or fish school. These rules are:

  1. Separation: steer to avoid crowding local flockmates
  2. Alignment: steer towards the average heading of local flockmates
  3. Cohesion: steer to move toward the average position (center of mass) of local flockmates

By applying Boids cohesion, alignment and separation rules, each agent stays in the vicinity of its neighbours and heads in their general direction, taking care not to overlap them.

References

  1. C. W. Reynolds. Flocks, herds, and schools: A distributed behavioral model. In Proceedings of Computer Graphics Conference (SIGGRAPH ’87), volume 21(4), pages 25–34, 1987.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.