Feb 13

Going to School

As an occasional scuba diver, it has been a privilege to see on more than one occasion the majesty that is a school of fish up close. I’ve often wondered what (if anything) is going through any particular fish’s mind as it effortlessly maintains its position in the school. It’s easy to see why some have begun to study entire herds, flocks, swarms, or schools as a singular complex organism.


About a year ago, using a few basic rules…

  1. Separation – avoid crowding neighbors (short range repulsion)
  2. Alignment – steer towards average heading of neighbors.
  3. Cohesion – steer towards average position of neighbors (long range attraction)

… I developed a simple schooling algorithm using Processing 2.1.1 in order to model this phenomenon.  In the model, there are predatory sharks (blue circles) and a food source (red dot).

I was surprised at how sensitive the schooling behavior was to the strength of the forces associated with the three rules above.  Certain combinations of varying reliance on separation, alignment, and cohesion meant that the behavior ranged from fish that wouldn’t school at all, to scenarios where several small schools would form from the initial.  In fact, getting the parameters just right (from my perspective anyways) to model realistic schooling behavior was non-trivial.  Perhaps this supports the notion that real life schools of fish are actually very complex systems that have been optimized by evolution over the course of millions of years.


Flocking Behavior Rules: Wikipedia

Modeling Knowledge: Nature of Code

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>