Miraculous tweaks / boids eating boids

The Edge has a 'third culture bookshelf' down the right margin of the website: what a fantastic list. One posthumous book, by Carl Sagan, has a nice review via amazon:

The values of certain physical constants such as the charge of the electron appear to be "fine-tuned" to produce a universe hospitable to the rise of conscious, worshipful life. But the universe is not all that hospitable - try leaving Earth without a space suit. Life took billions of years to take root on this planet, and it is an open question whether it made it anywhere else. To us carboniferous creatures, the dials may seem miraculously tweaked, but different physical laws might have led to universes harboring equally awe-filled forms of energy, cooking up anthropic arguments of their own.

This thought has surfaced in two other places recently. Further reading of Nicholas Harberd's Seed to Seed made me think of it. He outlines some of the steps involved in a thale-cress plant responding when its caught in the shade: there's a convoluted chain that includes a light-sensitive protein (that can detect certain frequencies, so it 'knows' when the light is actually coming though a leaf that's keeping it in the shade), that protein moving to the nucleus, there being a response there that alters the way another gene is expressed, and other things along the way being inhibited or amplified.

It struck me how strange the task is that Harberd has set himself: to map the evolved chemical processes that have produced adaptive behaviour. (In this case, moving resources to growing up, putting on hold leaf production, so that the plant can seek a way out of the shade.) Each of those building blocks of amplification, inhibition, dis-inhibition, transcription, gene-altering (and all the stages yet to be identified) are a reflection of the phenomenal force of selection. In a way, finding out the exact details is beside the point. (Well... of course, it isn't: Harberd's work on plant growth may, for example, have implications for crop production somewhere down the line.)

It also hit home with some force when my first Java model started doing its thing. (Oo, I haven't blogged about this yet!) I wanted this first one to be visual, so I made a little torus world where two types of 'boid' flew about: one lot were the prey, the others predators. Each of them had two ways of seeing: two sets of fields of vision, each of which could only see either prey or predator. Each set had three different 'eyes'. So that's six 'eyes' in total. Picture each eye as a polygon, with eight points at a random distance from the boid. When the appropriate type of boid enters into this field of vision, the boid in question reacts - again, initially randomly. They go in a random direction, relative to the boid they've seen, at a random speed. If they see with more than one field of vision, then each new direction is summed. They have momentum, so they can't just magically change position.

So: this means that to start with, some predators, on seeing a preyboid, will try and run away from their food. These poor sods, therefore, don't eat. If predators don't eat, they eventually die of hunger. (Prey only die if they're eaten.) Equally, prey can go for the Darwin award if their random rules send them happily into the jaws of a predator they see.

When a boid dies, breeding occurs, keeping the number of boids steady. Two boids of the appropriate type are selected (randomly, but with a large bias towards the boids who have survived longest - so that age endows a boid with more breeding potential, but no part of the gene-pool is closed off) and their genes are crossed. ('Genes' include each of the eight points of the six fields of view, and the various relative directions and speeds.)

Do they evolve? Yes, I think so: though I can only check by looking, in the current model, prey seem to be able to out-evolve predators. Eventually, less prey tend to die, at a ratio of about 1 to 2. (Though this varies, since I don't use the same random seed each time. I should change this so's particular outcomes can be repeated...) On some runs, its more pronounced than others: predators seem to be able to lock on to prey and chase them over a fair distance. Prey seem to learn to get out of the way. (See below if you want to download and run the thing.)

But the thing that struck me most was how the evolutionary process seemed able to take advantage of whatever 'features' of the code they found. One example I can't show, since I've corrected the code now: the boids had a slight tendency to go east to west. This led to preyboids often evolving a cunning survival technique: if they found themselves behind a predator, they would learn to stay there, and follow them - since it was highly unlikely that any predators would be coming in the other direction. Sneaky. Also: there is still a fault in the way speed is summed, I think, so that a boid can move faster when it detects movement. This is something the predators can evolve to take advantage of: they can react off each other to gain more speed than they would alone. I presume this leads to them eating more: certainly, they can sometimes be seen chasing prey in little packs - and the prey attempt to get away just as quickly.

(At some point when I have lots of spare time, I'd love to improve the program, so that there is more flexibility in the boid's potential evolved behaviour - particularly in how they actually respond to sighting other boids. I'd like to see more group behaviour selected for: I think this is what's happening when e.g. the predators start clustering. See below on how to set up the program to produce this behaviour.)

The upshot of all this - well, the Sagan review nicely puts it: 'different physical laws might have led to universes harboring equally awe-filled forms of energy, cooking up anthropic arguments of their own.' Similarly, emergence (in which I include adaptation) in this simple program allows the boids to take advantage of whatever world they're presented with. Maybe the same does apply to the meat-world. Which is to say, I can't help but wonder that the laws of self-organisation are more fundamental than the laws of physics.

Its impossible to prove that some set of self-organisation 'laws' really could take advantage of whatever physical laws they were presented with: maybe certain universal constants would have led to a uniformly dead universe where no emergence could get a toe-hold (or a grip with whatever dangly appendage eventually evolved.) But nevertheless, I shall speculate wildly that emergence could be at home in many sets of physical reality. As Kauffman says, life is at home in the universe. (It's also somewhat difficult to really call them laws, in same way that, say, the laws of gravity are. What are they? Universal guidelines? Hur hur...)

But then I start to get worrying thoughts - I've waffled inconclusively about this before. That I have a 'plausability issue' with an emergent universe, much as a creationist has a 'plausability issue' with evolution. (Thus I'm well aware of how much a Dawkinsite would scoff at me. If I can't understand how, that just demonstrates something about my capacity for understanding, not anything about reality...) But, well, what if this speculation is true? That laws more fundamental than whatever substrate of reality they're acting on lead to life. Hmm. Absolutely no way to prove the original speculation, though, that I can see. Maybe Kant had the right idea: yup, there's a whole area of reality we can't know anything about. So there's no point thinking about it.

But surely... yeah, there's definitely a point speculating about it. Its what 'lying in fields on warm summer evenings' was invented for. The first thing that occurs to me is that Kant wanted to make a distinction between phenomena - the sense perceptions we have of the world - and noumena - the 'thing in itself', the source of those perceptions that we can never know 'in itself'. We can only ever receive a reflection of reality, presented to us by our categories of understanding and perception. I can't quite explain why, but it seems to me that emergence doesn't quite fit into either of these two categories.

Aaanyway, I have a dissertation to write, so I'll end inconclusively and mystically once more. But I think this is an interesting notion about metaphysics: no, you can't get any solid answers, and maybe never can. But that's kinda beside the point. Shouldn't people anyway cultivate an ability to waffle about it? Tempered by a good grip on reality, sure - but nevertheless, shouldn't we admit that an analytic approach that aims to logically seek answers isn't entirely the point of being human (though part of it)? I think I'd rather talk to someone who thought that the Flying Spaghetti Monster made the universe than someone who got all shouty about not speculating at all on stuff we can never know.

I think the question 'where did the laws of emergence come from?' is such a question. It doesn't actually make any sense as a question, not in the world we live in. They just are - mathematically, solidly, immutably. Such things can't come from anywhere. But its a useful question, for me, because it messes with my categories of thinking and pulls and pushes the imagination in several directions at once - and that can't be a bad thing.

For one thing, it does away with the notion of a God who's somewhat like a universal Roman emperor, wielding omnipotent power - but is currently not paying us any attention (being, perhaps, pre-occupied with answering the prayers of Hillsong members on behalf of their bank balances, whilst somewhat bizarrely ignoring the billion people who went hungry last night.) Its a 'plausability in imagination' thing again: whilst one might imagine a universal programmer twiddling with the initial values of the world's parameters, its considerably more challenging to think such a thing is possible when it comes to emergence. Its even less plausible that such a universe is likely to care whether I have sex before marriage, or work on Sundays.

Anyway, I'm sure I said I'd stop waffling about it...

--------

To run the boids evolving program:

1. Download the zip file from here.

2. Unzip onto the C drive. It'll unzip as a folder called dist. (This contains the source code btw, if you wanna gander, in the src folder. You'll find the main routine in BoidsCage.java; its fairly well documented.)

4. Run the command line prompt. (In windows, go to the start menu, click 'run...' and type 'cmd'.) Navigate to the dist folder. (In windows: you might find yourself in the wrong folder, so go back to the C root with 'cd \' then get to the dist folder with 'cd dist'. It should run on any system with Java installed, but I don't know if e.g. macs have the same command line commands...)

5. Paste this into the command line: java -jar "BoidsEatBoids.jar". It should run.

6. Things to note on running: Start button to start. Clear button doesn't do anything! Use the wheel on the mouse, or type in values, to change:

a. number of boids. Says zero, but starts off as 28. The number is the number of each type, so 28 is 56 in total.

b. Turning speed: currently on 1/6 of a full circle max. Change this to 4 if you wanna see the predators do some strange clustering hunting thing.

c. Display speed: increase this to slow them down, to see their movement more clearly.

d. Display field of view rule: scroll through these when the boids are flying to see the current fields of view. Notice that, if you leave it running for a long time, these will end up all the same for the specific species. They'll be in an evolutionary cul-de-sac, with no mutation to get em out.

7. Note: the control panel will display the current total number of prey and predator deaths.

8. Also note: the boid in the blue circle - originally to see whether some code changes worked, but I've left it because its quite useful to be able to follow one with the eye, and see how they learn to avoid being eaten.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
More information about formatting options Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.