Monday Miscellany

A few little things for Monday. I made a new video using the same engine as the fish school simulation described in the post In This Virtual Fish Tank, You Make the Rules.

This video shows 5000 fish swimming while the weightings of the three behavioural rules vary using sinusoidal functions. I love the “borders” created as large fish schools collide, and fish attempt to escape along the plane of intersection.

Triumph of the Golden Rule was also linked to as recommended reading for MIT course 6.033 Computer Systems Engineering – one of the best compliments I’ve received. Thanks Evan!

In This Virtual Fish Tank, You Make the Rules

In my last post, I discussed how individuals following simple rules cause cause coordinated group behavior to arise. The boid model created by Craig Reynolds used three rules – alignment, separation, and coherence. But how much attention does each individual pay to each rule? In situations like migration, alignment might be the most important rule. If you’re being attacked by predators, sticking together and paying attention to the coherence rule might keep you from being eaten.

Clearly different situations might have different approaches. I was very interested in how different weightings of these rules might behave, so I decided to create a program that would allow you to change the relative importance of each rule at will. You can see a video of it in action below (the three sliders on the bottom left control the influence of the various rules).

Smaller screen, older computer, or just want something more simple?
Load the standard definition fish school simulation.
Big screen, fast computer, and want to give the fish some more room to swim?
Load the high definition fish school simulation.
Alignment: This slider adjusts how much each fish wants to head in the same direction as other fish around it.
Cohesion: This slider adjusts how close each fish wants to be to its neighbors.
Separation: This slider adjust how much each fish wants to space itself out from the others.
Click anywhere in the water to add a new fish.
Press this button to reset the simulation.

I hope you enjoy it – please leave me a comment if you have any questions, comments, or find any bugs.

Herds of Android Birds Mimic Ad Hoc Flocks

In winter during the late afternoon before settling down to roost, flocks of thousands of starlings will twist and turn, turning the sky black with strange curves that seem to move with a mind of their own. The flocks of up to a million strong form for warmth, for security, and for social contact.

These seething clouds of birds have no leader, no planning, and yet produce a dance that seems choreographed in its precision and beauty. So how do they do it? Some strange ability given to them, a unique skill among the animal kingdom? Well, perhaps not quite. Consider that humans seem to be able to move in crowds with the same ease, although some might say with a bit less beauty.

People seem to move in clumps, in the same direction, and manage to not trample each other or collide. There seem to be parallels in crowds of organisms, that this order emerges consistently and that somehow each animal “knows” what to do on a small scale, resulting in cohesive and sensible group movement. The question then becomes – what exactly are we doing unconsciously to organize like this?

The Boid Model

In 1986 Craig Reynolds produced a computer model describing how large groups of animals such as schools, herds, and flocks could be able to move in unison with no central coordination. He called his creations “boids”, and imagined that each would follow some simple, sensible rules to navigate around. He also knew a single animal would never be able to keep track of every other animal in the group, and assumed that they would only pay attention to their immediate neighbors in the flock.

So if you were a boid, what rules would you follow?

Alignment: Look around you. Where is everyone else going? Probably a good idea to go there too. Alignment is a rule that finds the average direction your neighbours are going, and tells you to go there too.
Cohesion:Predators look to pick off stragglers on the edge of the pack. Cohesion is a rule that finds the average position of your neighbors and tells you to go there, pulling you into the relative safety of the center of the pack.
Separation: When crowds get big, they can get dangerous. Animals can trample each other, and birds can collide. Separation is a rule that tells you to make sure to give your neighbors some space.

How do we know how to do this? Well, the tautological answer is that it simply works. The beauty of these rules is that each of them is amazingly simple, and seem to make sense to us on an intuitive level. We tend to go with the crowd, stick together, and still try to give everyone a bit of personal space. But are these rules enough to produce the complex dance of the starlings, or are we missing some detail?

A Boid Dance

It turns out these simple rules produce patterns of movement that are anything but.

We can see that it looks flowing and wonderfully organic – but it’s not quite the same as the starling flocks. We can play with the boid model, tuning its various parameters to see how the resulting crowds might react.

A school of fish trying to avoid predators might be modeled best by weighting the cohesiveness rule very heavily, attempting to keep together at all costs while not worrying too much about personal space or where precisely they’re heading as long as it’s away from what’s trying to eat you.
A flock of geese flying south for the winter will focus on heading in a certain direction (alignment), then space themselves out to ensure they can see in front of themselves (seperation) while staying close enough and on the same plane to experience the aerodynamic benefits of flying in a group (cohesion) producing the “flying V” we see so often in fall.
Migrating animals are primarily concerned with making sure they’re going in the same direction as everyone else (alignment) while ensuring that no one is trampled (seperation) and that young and weak animals are protected in the center of the herd (cohesion). For instance, the wildebeest stampede that killed Simba’s father in the Lion King was generated using the same theory as the boid model.

This simple model has a wide range of possible applications, and a huge amount of flexibility allowing it to produce a wide range of behavioural simulations. This gorgeous installation of light graffiti uses the rules we’ve just discussed to create hypnotizing patterns of artificial creatures.

The boid model has been used to animate realistic looking behavior over a huge range of media. If you’ve seen a computer generated crowd moving in a vaguely sensible manner anywhere, it likely uses the same basic theory. The power of the model comes from its construction, assuming simple behaviors competing for influence that result in a complex outcome not unlike our own consciousness or political systems. Not too shabby for a research project from over 20 years ago.