evgiz.net
February 20, 2019

Complex emergent flocking behavior

Many animals such as birds and fish exhibit complex flocking behaviors in nature. Boids is an artificial life simulation which attempts to capture some of these flocking attributes. Interestingly, very complex behavior can emerge from a group of individually acting entities following simple rules. This article describes my implementation briefly, and contains several visualizations of interesting flocking behaviors I have observed.

Cohesion, alignment and avoidance

Each entity follows a simple set of rules, which together determine the directional vector they should align with. My implementation uses 3 spatial dimensions, but the same concepts apply in 2D as well. By varying the weight of each rule as well as other parameters, a large variation of behavior can be observed.

Which entities are considered immediate neighbors is determined by a set range. Together, these three rules result in quite complex flocking behavior.

Figure: emergent flocking behavior of fish in a 3D environment

My solution includes three different "species" who will never consider each other neighbors, regardless of distance. The rules can be tuned by a number of parameters.

Figure: dominating cohesion rule resulting in dense swarming behavior

Figure: dominating alignment rule resulting in long or wide schools of fish swimming in parallel

Figure: dominating avoidance rule resulting in chaotic and widely dispersed schools

More complex and interesting situations can also be generated. I have added a predator which follows a slightly different set of rules.

In addition, all prey will ignore their original rules if a predator is sufficiently close - instead moving directly away from the danger.

Figure: predators (in red) cause schools to split more frequently since individual prey prioritize themselves

Conclusion

Boids is an interesting example of complexity emerging from a simple set of rules. I am curious if a similar concept has applications in a machine learning context. It could potentially be a solution to certain complex cooperative tasks if the task can be sufficiently divided into smaller pieces. I might explore this idea sometime in the future!