Skip to content

gstarch/boids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boids Flocking Simulation

Introduction

This is a naive p5.js implementation of the "Boids" flocking algorithm described by Craig Reynolds in 1987:

Flocks, Herds, and Schools: A Distributed Behavioral Model – Reynolds, C.W. [Computer Graphics 21(4), July 1987]

This version has been stripped down for sharing, but it was a component of a larger visualisation assignment. Some vestiges might remain.

If you are interested in more interesting variations like Perlin noise, predators and beat mapping, please email me.

What is a boid?

A boid is an artificial agent that moves on a 2D canvas and detects other boids that are nearby. The boid is influenced by the balance of three behaviours:

  • Alignment: Boids like to steer in the average direction of their close neighbours.
  • Cohesion: Boids like to adjust their velocity to match nearby boids.
  • Separation: Boids need a bit of space and will steer away from boids that crowd them.

In addition, a centre-seeking force is applied when boids approach canvas boundaries. An alternative solution is to wrap around to the other side of the screen (as seen in the Daniel Shiffman version).

Boid Flock

Acknowledgements

  • Craig Reynolds (wikipedia | github) for being the mind behind the core flocking behaviour algorithm known as Boids.
  • Daniel Shiffman(wikipedia | github) for his incredible enthusiasm and ability to inspire creative coders everywhere. Visit The Coding Train to see more of his amazing materials and tutorials. He also created a Boids example for the p5.js project which helped me a lot.

Further Reading and References

Books

  • Braitenberg, V. (1984). Vehicles: Experiments in Synthetic Psychology. MIT Press.

  • Bourg, D.M. & Bywalec, B. (2013). Physics for Game Developers. O'Reilly.

  • Shiffman, D. (2012). The Nature of Code. The Coding Train.

  • Vince, J. (2001). Mathematics for Computer Graphics. Springer.

Articles

About

Boids Flocking Simulation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published