December 23, 2005

Follow that bird

Looking out at the sky as I write this: two or three kites up high, wheeling lazily; lower down, the occasional crow, then a pigeon that flaps frantically from one building to another. And out on the shore, I finally see what I want to write about: a small flock of stints that rises as one, turns, catches the sun, turns again ...

You've seen birds behaving this way, I'm sure. (Pigeons do it, too). Individually, they seem so ... well, individual. But flying together, they show a strange collective thinking and behaviour. If you watch such a flock, you begin thinking there's something uncanny going on. How do hundreds of individual movements translate into this graceful togetherness?

Flock-watchers had always thought that there must be a complex set of rules that each bird followed. Collectively, they produced the smooth, acrobatic and intricate movement we see. Complex movement? Must come from complex rules. So they thought.

Until 1986, when Craig Reynolds, a computer animator, blew a hole in that thinking. After many hours watching birds, he came to a quite different conclusion. Flock movement, he thought, could be explained by three very simple rules for each bird to follow:
  • Move towards the average position of my flockmates; that is, towards where there are the most birds in the flock (cohesion).
  • Maintain the same speed and direction of flight as my flockmates (alignment).
  • Keep a discreet distance from my flockmates to avoid bumping into them. In fact, keep a discreet distance from all other objects (separation).

Reynolds wrote a programme to implement these rules, and used them to simulate the motion of a flock of birds on his screen. He called his simulated birds Boids.

Boids astonished everyone who saw them. Even in large numbers, they flew in a manner eerily reminiscent of their real-world counterparts. When the programme started, boids placed randomly all over the screen would quickly move towards each other and maintain the same direction. A stable configuration emerged at the centre of the flock; boids at the edges regulated their speeds to stay with the group. Even obstacles that Reynolds put in the boids' path did not trouble them. The simulated flock would approach a simulated pillar, split up at exactly the right moment, fly around it and reassemble -- just what birds would do.

As a whole, the simulated flock showed the same fluid, elegant moves that real ones did. In fact, they moved so realistically, so convincingly, across Reynolds' screen that ornithologists began to call him to find out what his rules were.

Reynolds had clearly hit upon something. But what was it? It was too early to say whether individual birds actually followed his rules -- but that hardly mattered, because flock behaviour was so spot on. This was the remarkable part, because nowhere in the Boids programme were there instructions about how the flock as a whole should behave. The rules applied only to individuals. Yet those rules were enough for the boids to "learn" how to form and maintain their flight pattern as a flock.

Collective behaviour, from three simple rules applied to individuals.

The boids experiment was successfully repeated with other animals. Programmes have simulated the behaviour of schools of fish and colonies of ants; even the movement of crowds entering a stadium, and this suggested where best to place ticket collectors. Reynolds' work even achieved some Hollywood fame: it was used in the stampede scene in "The Lion King".

All of which reinforced the same lesson. Simple individual rules produce complex collective behaviour. Complexity, from simplicity.

There are some interesting insights from these ideas. For example, the boids are an example of "bottom-up" programming. In more conventional "top-down" programming, you list thousands of individual instructions for your computer to follow. Bottom-up, you simply lay out a few broad guidelines from which the desired outcome emerges. Of course, there's hard work in finding those few guidelines. But if you can, your programme is simpler, easier to understand, and still does the job.

You might see our entire education system as top-down. We fill student minds with rigid stuff about one or the other subject, most of which they memorize. But we rarely teach them the ability to solve their own problems. So at the first metaphorical pillar in their paths, they fall flat instead of flowing smoothly around them like boids do. What if we instead gave our students a framework, some guidelines on how to learn? Hard work searching for those guidelines, yes. But we might then set them free to explore and learn on their own.

Another example: taken one at a time, our nerve cells simplicity itself. They react to chemical stimuli. Even more simply, they switch on, they switch off.

But when millions of such cells are connected in ways we don't yet fully comprehend, as in our bodies, something unexpected happens. Suddenly, you have thoughts, emotions, language, art, religion. In other words, intelligence, even though there's religion. And all from the ordinariness of nerve cells!

So now ask: did this article make sense? Whatever your answer, it is really just dots of colour sprayed on your screen according to some rules. Puts it in some perspective, you think?

8 comments:

Anonymous said...

"All I know is that I do not know anything" - Socrates

And that is in double quotes as he might have quoted someone else :)

- Z

Suhail said...

Superb stuff!
But this won't apply to long-distance migratory flight paths, especially the cranes or geese who follow a strict flight regimen, of switching the leader periodically, who gets sent back in the queue to work hard and flap wings, rather than ride the thermals.
Also, this article is a worthwhile read :"The captive-bred whooping cranes make their journey in a very different way. The young birds in the new reintroduced Eastern flock will be flying with an ultralight plane instead of with adult cranes leading the way".
All fantastic stuff. Reminds me how much I miss NGC.

Abi said...

Another nice one, Dilip. Thanks.

The concept you have described now goes by the name "emergence". Check out the Wikipedia entry.

You have illustrated it using living organisms. The same thing applies to inanimate objects as well. For example, atoms come to gether to produce certain well defined patterns. The underlying interactions among the atoms are actually simple, but they are capable of producing a very wide variety of pretty complex patterns.

Other examples would be sand patterns in deserts,
river patterns near the delta and meandering of the river.

In social sciences, similar ideas are used under the name of "agent-based models". They have already produced some stunning insights into large scale social behaviours. Philip Ball's piece on it in Physics Web is a good starting point to explore these connections (and follow some of the links there). Ball has also written a book called "Critical Mass: How One Thing Leads to Another".

Sunil said...

good stuff!

Kartik said...

Wonderful stuff Dilip - looking for more such posts :-)

Reminds me of logic programming languages - Prolog, etc. the like - define a set of rules for individual elements, and then it doesn't matter what you add on, everything just "knows" what to do in the end. It just WORKS!

Bet Reynolds used some of that -

Anonymous said...

Mr. DSouza,

Super post this one. You have some visualisation capacity, I must admit. Beautiful.

Cheers,

A. Dodger

P.S.:- You asked me if I liked the LA Dodgers. Nopes, cuz I wear Red socks.

wise donkey said...

:) a good one.
and i couldnt help wondering why humans seem to lack it.

why there are stampedes. not just during collection of relief materials but when it comes to a tirupati darshan or when catching a bus
or why do we have traffic jams.

and then i realised that these flock perhaps dont have an individual goal. no one tells them, you have to do this, to get food, but then not all might get it, always.

there is no pressure on them to being the first one, the best one, or the fastest one.
no one would make them think that you are a loser if you give way.

hmmm good post:)

Raj said...

Gem of a post.