SOME of the mysteries behind the "greatest wonder of nature" have been revealed - thanks to a computer programme devised by York boffins.

Mathematical biologists have for years been trying to work out how and why birds and fish flock together so expertly.

Thanks to the software, they are now one step closer to an answer.

Wildlife expert Bill Oddie once described the spectacular twilight flocking of starlings as the greatest wonder of nature.

The nightly display by thousands of birds has even caught the eye of advertisers, but the reasons why the starlings do it has tantalised scientists.

Dr Andrew Wood, from the University of York's biology department, worked with colleagues at the University of Edinburgh to set up a computer model which may provide answers.

They say it accurately predicts behaviour which allows the individual creatures in the flock to evolve and change.

They discovered that when creatures simulated in the programme were subjected to evolutionary pressure - such as avoiding predators and finding food - two entirely separate types of flock could emerge.

One model meant the flock as a whole was more efficient, while the other maximised the efficiency of each individual relative to its fellows.

Dr Wood said: "The computer model describes many types of flocking or herding behaviour of individual creatures - from the dense mills of schooling fish to the tumbling flocks of starlings.

"Our results suggest that this model accurately mimics real groups, and will give us a better understanding of this behaviour."

The findings - in a paper entitled Evolving The Selfish Herd - are published in the latest issue of the Proceedings Of The Royal Society: Biological Sciences.

The University of York's biology department has one of the best records in research in the country.