Who hasn't looked up in awe at a perfectly formed flock of birds soaring through the sky, or marvelled at the beauty of a glistening spider's web? Ever wondered how they do it? In his new book, `Life's Other Secret', Ian Stewart says that it's all down to mathematics
Click to follow
One January, I was visiting friends in Monte Carlo, and I witnessed one of the most extraordinary sights I have ever seen. From high up in one of the innumerable tower blocks that climb skyward from the tiny principality's precious ground, I was looking down into the harbour, jam-packed with expensive yachts, glowing in the light of the setting sun. Way down below me, in among the high-rises, was a huge tree - a tree laden not with fruit, but with birds. Literally thousands of birds - they looked like starlings but I can't be sure - were spiralling in to settle down for the night.

The sheer concentration of birds was amazing enough - but there was more. As the birds dipped and wheeled in the sky, the entire flock slowly began to acquire some kind of collective order. At first, it seemed little more than a random swarm of independent birds, a vast fuzzy scattering of black dots in the sky, but as the sun dipped lower, the entire flock slowly began to act as one - like some gigantic, ethereal skyborne organism. The flock acquired sharp edges, a dense black swarm with its own collective will. The swarm spiralled through the sky, swerving and turning with astonishing speed and an impressive unity, as if each bird knew exactly what to do. Occasionally, a large clump would split off, whirling and swirling in its own independent dance - yet soon it rejoined the main group, as if drawn by an invisible magnet. A few stragglers flapped aimlessly about, apparently seeking to join the main flock but unsure of the best route; the majority of the birds behaved as one. Then, magically, the flock dispersed: the dance was over.

There is something awe-inspiring about large groups of animals - especially their apparent unity of purpose. We wonder where it comes from, how the individuals know what the group is supposed to do, and how they play their part in achieving it. It is not just flocks of birds that exhibit striking patterns of collective behaviour. Schools of fish create glittering swirls of movement in tropical oceans, flashing this way and that, but never leaving the group - stopping and starting in an instant. Huge herds of wildebeests trek for hundreds of kilometres across the African veldt, following the tracks of ancient migrations, millions of years old. In some parts of the world, termites construct weird vanes, deep below ground, to equip their nests with air-conditioning.

What can possibly be responsible for the remarkable behaviour of social animals? What gives them the appearance of possessing a group mind, as if some central conductor were orchestrating their behaviour? Catchall terms such as instinct only deepen the puzzle: for what is instinct? How come a humble termite is so massively endowed with instinct that a group of them knows how to install air-conditioning in the nest? It's not instinct. It's rules. Over hundreds of millions of years, evolution has exploited patterns of collective behaviour that arise, spontaneously, from the abstract mathematical rules that physics provides. It has built those patterns into the animals' genes and their social behaviour, some of which may be passed on through learning, not genetics, at least in the higher animals. Evolution has not built in the patterns directly, however. There is - I strongly suspect - no genetic instruction "form a flock" in a bird. Instead, there are genetic and behavioural analogues of the rules that produce flocks. Evolution has constrained the repertoire of bird behaviour, both genetically and culturally, to incorporate such rules.

Why do I think evolution has favoured the rules themselves and not their consequences? There are four reasons. The first is efficiency; on the whole, the rules are simpler than the behaviours they generate. A few rules, with built-in contingency planning, can encapsulate a huge range of behaviour, adaptable to a huge range of circumstances. Rules, quite simply, require less information.

The second reason is consistency. If bird behaviour, say, were represented in the organism as a long list of what the bird should do for each particular set of circumstances, then genetic variation could easily change one item in that list in a manner that is inconsistent with the others. A rogue mutation might cause birds to flock, except when they encounter a river, say. The flocking of migrating birds would then be hopelessly disrupted. In order for bird behaviour to maintain its internal consistency as it evolves, it is much better to adapt by modifying the underlying rules.

The third reason: adaptability. Small changes in rules can cause big changes in behaviour. Therefore, behaviour can evolve more rapidly, while remaining self-consistent, if it is stored as rules.

The fourth reason is that it's hard to see how individuals could perceive and act on the overall characteristics of group behaviour. Could bird genes contain instructions such as "the flock should cluster more tightly when a predator is sighted"? It's hard to see how. If this were the case, each bird would have to somehow be aware of the state of the entire flock; moreover, it would have to become instantly aware if another bird has sighted a predator. It seems far more likely that the individuals obey such rules as "try to stay close to your immediate neighbours" and "if you see a predator, stay even closer," or even "if your immediate neighbours are clustering around you more densely than usual, start to watch for predators." Rules such as these, which do not require improbable acts of omnipotence from individual birds, but which can generate the observed collective behaviour, make far more sense: local rules, rules that involve only what an individual can reasonably be expected to perceive.

Circumstantial evidence supports this contention. We know that humans in crowds are generally unaware of the overall behaviour of the crowd because crowds can sometimes become dangerous to the people in them without anybody realising until it's too late. Most countries have a catalogue of tragedies involving the unintelligent behaviour of crowds. Yet the individuals in these crowds are intelligent. But, they are aware only of their immediate surroundings; they can't see around corners.

When we do try to understand group behaviour in living organisms, the need for mathematics becomes overriding. Why? Because group behaviour involves not just organisms, but also interactions among organisms: the behaviour of systems. Mathematics teaches us that such behaviour can often be wildly counterintuitive - and offers the prospect of improved intuition. So between rules and the resulting behaviours lies an expanse of intellectual territory that mathematicians are claiming for their own. We certainly do not understand the patterns of behaviour in animal societies nearly as well as the animals do. However, we are beginning to understand that much animal behaviour has a mathematical basis; that a great deal of it is considerably less miraculous than appearances might suggest; and that a set of mathematical rules, hard-wired or otherwise programmed into animals' nervous systems, can generate far more subtle behaviour than we would anticipate.

But what kind of behaviour do you get from obeying - slavishly and literally - a few rules? How much of the social behaviour of living creatures can be explained in this manner?

Mark Tilden makes robots. In his laboratory in Los Alamos are about 200 tiny solar-powered robots and he has designed and built a robot that follows sunbeams around a room. Once inside a patch of sunlight on the floor, the robot appears to go to sleep. As soon as the patch moves on, it appears to wake up, nose around for a few seconds, and follow the patch, going back to sleep as soon as it is back in the daylight. It's not a big robot, but it does an admirable job. Observing its behaviour, you would imagine that some pretty smart electronics and some fancy programming had gone into it: it must be able to recognise the boundaries of the sunbeam, calculate how to move to get well inside the boundaries, and track the boundaries as the sun moves across the sky and the shadows move with it. Not so. This is a remarkably stupid robot. It doesn't even know what sunlight is. All it does is constantly to scan its electrical input from the solar array, and follow three rules:

1 If your solar cells are not generating more than a certain level of power, spin at random and move 10cm forward.

2 If they have been generating power above set level for under five seconds, move forward in a straight line at constant speed.

3 If they have been generating power above level for over five seconds, stop.

That's it. Until the robot finds a sunbeam, it obeys rule one, and it spins, moves, spins again, moves again, zigzagging across the floor. Eventually, it encounters a sunbeam, at which point rule two kicks in, and it keeps going in the same direction. If it's still in sunlight after a few seconds, rule three takes over, and it goes to sleep. As soon as the sunbeam moves on, the zigzagging begins anew - and the same happens if by some chance the robot runs across the corner of its sunbeam back into the shade.

The robot looks as if it possesses an intelligent and highly adaptable ability to follow patches of sunlight. Actually, it's just obeying three rules. Single-celled creatures that respond to light may well obey a similar set of rules.

The moral: Don't underestimate the efficacy of rules.

My next example gets closer to real organisms: It is the brainchild of zoologist, Fritz Vollrath. It concerns not a collection of animals, but just one: a spider. Nevertheless, it again addresses the relationship between general rules and the specific behaviours that appear when those rules are applied in some particular set of circumstances.

Most of us have been impressed, at some time or another by the cleverness of a spider, spinning its delicate web. Vollrath thinks he knows how they do it.

He has created mathematical "cyberspiders" that build realistic webs by following a few rules. They are not actual robots; they are computer simulations. With the right engineering, however, you could make a robot spider and set it to work catching robot flies - assuming you could get tiny robots to fly. Vollrath deduced his system of cyberspider rules through a mixture of observations of spiders and experiments with computers.

The versatility of spiders is astonishing, the variety of web designs more wonderful than the assortment in any mail-order catalogue. There is the traditional web that looks a bit like the wires on a dartboard, spun by spiders such as Nephila clavipes, the orb weaver spider. There are many other designs of web, too. Some are so simple that they look somewhat pathetic: Magrammopes, the tropical stick spider, goes fishing for flies with a single line. Hyptiotes, a devotee of minimalism, builds a triangle. On the other hand Scoloderus, the ladder-web spider, is an accomplished artisan that weaves a web like a ladder. Latrodectus, the infamous black widow, builds a web that is narrow at the top, broad at the bottom, and reaches down to the ground - a funeral drape for the unfortunate insects that blunder into it. And Liphistins, the trapdoor spider, lines a deep hole with threads, covers it with a trapdoor, and extends sticky tripwires out into the nearby terrain, to serve as an early warning system. Liphistius is a living fossil; its ancestors built similar webs 380 million years ago. It is believed that all modern spiders are descended from ones that built webs like Liphistius's.

Spiders are tireless workers: most spiders construct a new web every day. Each web differs subtly from the others, depending on where it is be built. These variations demonstrate the enormous flexibility of the spider's web-building system: too flexible to be just a simple list of actions coded in the spider's genes. Rules, however, are another matter entirely. The shapes of webs are clues to the spider's rules.

Here's what Vollrath thinks the creatures do. These are the rules for the traditional dartboard web; similar rules govern other webs. The spider begins by exploring the web site, trailing its silk thread behind it. When it finds a suitable place it strings a thread between two shoots or branches, climbs out along it to the middle, and lowers itself to the ground, creating a Y shape. The part of the Y where the threads all meet will eventually become the hub of the web, and the arms and upright of the Y are the first of many radial spokes. The spider climbs back up to the hub and starts to walk around and around, making a tight spiral and adding new spokes. Then it forms a widely spaced temporary spiral, which plays the role of scaffolding for the final web and is torn down as the web nears completion. It now builds a capture spiral. Starting at the outside of the web, usually near the bottom, it zigzags to and fro, working slowly inward. Nearer the centre, it starts to move in complete circles. Finally it fine-tunes the tension in the web by making adjustments at the hub, settles down, and waits for a fly to come into its parlour.

That's the method in outline. At the next level of detail, we must ask how the spider plans its web, what constraints there are on the numbers of spokes, and how it spaces the strands; Vollrath has worked out effective rules for those, too. For instance, when it comes to deciding how many spokes to make, the spiders seem to be unhappy if adjacent spokes are separated by too large an angle, so they add new ones until all angles are acceptable. They measure the spacing between the threads of the capture spiral with their front two legs-just like a tailor measuring cloth.

Spider genes can easily equip spiders with rules of behaviour - say by programming the architecture of the spider's nervous system. Which genes do what is a question for genetics, but the effect of those genes on behaviour involves the link from rules to their conse- quences, and to understand this requires mathematics: as usual, a partnership. Vollrath's ideas show us what kinds of rules the genes must encode.

Rules encoded in genes can evolve - and again we need mathematics to understand the resulting patterns. Indeed, Vollrath uses a mathematical technique known as a "genetic algorithm" to study how the spider's system of rules could evolve in the first place. The adjective genetic indicates that the mathematics borrows a useful trick from genetics, not that it works directly with spider genes.

An algorithm is a method for solving problems on a computer - a list of the precise steps required to carry out a desired computation, a list that comes with a guarantee that the computation will stop, with the correct answer. Most problems can be solved in many different ways, and the object of much computer programming is to find the most effective algorithm - the one that solves the problem the most quickly, using the least amount of memory, or satisfying some similar criterion. A typical task is solve the "travelling salesman problem." The salesman has to visit every town on some list, but the order in which he visits them is up to him. What's the shortest route that visits every town? When the number of towns becomes even moderately large, it is impossible to solve this problem by listing all possible routes and seeing which is shortest - the number of routes becomes far too big. Some other strategy has to be used to solve the problem - or, at least, get close to a solution, because for practical purposes, it's more important to get a reasonably short route quickly than it is to spend aeons trying to get the absolutely shortest one. The genetic- algorithm approach starts with several randomly chosen routes. Then it chooses two of them at random and sees whether it is possible to combine the best features of both to get an improved route. In effect, this method cross-breeds the two routes and sees how good the offspring are. Shorter offspring are retained, longer ones are killed off - removed from consideration. This algorithmic approach is a deliberate analogue of Darwin's concept of natural selection, and it has the same effect. By repeating the process many times, extremely effective algorithms can be evolved.

In contrast, it is often difficult to design good algorithms from scratch if the range of alternatives is too big. It is in just these circumstances that genetic algorithms come into their own.

To see how rapidly a rule-based system for web building can evolve to build effective webs, Vollrath applied genetic algorithms to his cyberspiders. Working first with Nick Gotts and later with Peter Fuchs, he equipped the cyberspiders with their own "genes" - computer codes that represented their web-making rules. Then he cross-bred them, mixing bits of codes from two distinct parents, and imposed a form of natural selection; the ones that make more effective webs (effective at catching cyberflies, that is) survive to pass on their genes; the ones that make really bad webs do not. Using genetic algorithms, Vollrath found that it takes no more than 50 generations to breed highly effective cyberspiders.

The message here is mathematically exciting but biologically sobering. It is that apparently complicated and flexible animal behaviour patterns can be generated by much simpler, and more rigid, rules. Evolutionary selection is based on the effectiveness of webs - but selection works by eliminating spiders whose web-building rules produce less effective webs.

What drives spider evolution is the rules, not the webs - and the same probably goes for much animal behaviour, individual or collective. This message is exciting, but also sobering. The excitement arises because of the possibility of explaining complicated behaviour in mathematical terms. The sobering message is that nature may not be quite as marvellous as it seems to be - though it is surely marvellous enough, and debunking a few behavioural patterns makes only the tiniest of dents in nature's richly deserved reputation for subtlety.


Life's Other Secret by Ian Stewart, from which this is extracted, is available to IoS readers at the special price of pounds 18 (RRP pounds 20) incl p&p. Please send a cheque/postal order made payable to Penguin Books Ltd or credit card details to: Life's Other Secret Offer, Penguin Direct, Bath Road, Harmondsworth, UB7 0DA. Offer subject to availability. Open to residents of the UK only. Allow 30 days for delivery. Offer closes 31 July 1998.