Monday, 22 April 2013

Angry Birds as Co-Evolution

Problem solved at the bottom chaps. 

I am pleased to say that Alex Churchill is now taking charge of the Python coding. Vera and I will continue to play a spectator role, eagerly back seat programming, while Goren looks on from afar saying physicist kind of things.

While Alex develops the molecule code for the Nao in Python, I am relieved of this task very gratefully and am able to think about other things. The first is to concentrate on the selection criteria for games. The Fisher fitness criterion is independent in principle of the molecular genotypes and the graph grammars that operate on them. This means I can develop a more abstract simulation that more rapidly tests the performance of various game selection methods, which is what I have woken up at 4.30am to do, since I have now time in my brain.

What is an appropriate domain in which to test the co-evolution of actors and games? It should be one in which by eye one can see that the behaviour is actually interesting, and so this really implies some kind of physics simulation, probably in a robotics setting of some sort with plenty of intrinsic dynamics. But then we're back to the Nao, or a similar faster simulation. The e-puck is another possibility of-course. An even more abstract setting would be the manipulation of discrete number sequences by re-write rules, the aim being to achieve particular sequences of letters, or the task may be to generate particular patterns from generative rules. The underlying generative rules evolve. The fitness of the construction is some property of the construction defined by the game, e.g. its ability to withstand a et of perturbations P. This set of perturbations evolves such that the variance of fitness for a particular set of perturbations is maximised over the set of solutions.



What should bird fitness be for the most "interesting" bird strategies and the most "interesting" buildings to evolve? 

Here is a thought about Angry birds and co-evolution. Feedback welcome, also volunteers to write the code welcome :)

The fitness of the construction is some property of the construction defined by a game, e.g. that construction P's ability to withstand a set of perturbations B. This set of perturbations B evolves such that the variance of fitness for a particular set of constructions on that perturbation is maximised over the set of tested constructions P. 

For example, consider a set of generative rules for self-assembly of a 2D construction (a la Angry Birds). The set of perturbations is defined by a combinatorial specification of position, speed, mass of projectile  and the projectile properties, e.g. explosive, breaks into 3 birds etc... The birds are the predators on the buildings basically (or the pigs which hide in the building and which are under the same selective pressure as the building itself), and the pigs are the pray. Now, if the perturbations (bird strategies) can evolve with their fitness being how well they destroy a building, and the buildings can evolve, their fitness being how well they withstand slaughter from the angry birds, then what kinds of 'ESS' will be obtained? 

Above we have a traditional co-evolutionary scenario rather than one where the games (fitness functions) are evolving on the basis of maximising fitness variance of solutions which is my proposal for what an interesting game is, see here. 


We have just two populations of co-evolving solutions that compete against each other in the standard co-evolutionary way, e.g. 


If the bird strategies were instead selected on the basis of maximising the variance of building fitness when faced with that bird strategy, then I'm not sure which bird strategies would evolve, and whether they would be any better than the standard co-evolutionary method above. Bird strategies which just dropped a bird in front weakly would die because all buildings would survive, bird strategies that dropped millions of birds would survive because they would kill all buildings, i.e. bird nuclear bombs are not fit because all buildings perform badly on this strategy. But bird strategies that resulted in a high variance of building fitness would survive, and this predicts according to Fisher's fundamental theorem of natural selection that the rate of building fitness increase will be maximised. 

What I'm not clear about is whether bird strategies selected for simply killing pigs and undergoing simple co-evolution with buildings evolved for protecting pigs, would produce more "interesting" buildings than bird strategies selected on the basis of maximising variance in buildings fitness on those bird strategies. 

This has implications for my theory of what is an "interesting" game for our brains. The implication of the above discussion for the paper "Design for a Darwinian Brain" is that games in our brains may not want to explicitly maximise variance in the fitness of solutions on them, but may just want to kill the solutions. So when I choose a game, it tries to kill my ideas. Those games which kill them more effectively survive. Well, the problem here is that if my games are too successful according to this criterion, all my ideas die. A game that kills all its ideas should also die I think. 

Anyway, I think its definitely worth simulating the two fitness functions for bird strategies above and seeing what different kinds of solutions and buildings evolve in both cases. 


It seems it should be possible to make a kind of Angry-Birdsy co-evolutionary simulation using JavaScript's box box which is a wrapper for the same physics engine that Angry Birds actually uses.

How to make an Angry Birds Clone in JavaScript...
http://training.bocoup.com/screencasts/make-your-own-angry-birds/
http://incompl.github.io/boxbox/

Lets try to create a simple co-evolutionary game in boxbox now in which projectiles invent a strategy for destroying a construction (building) which must protect some entities (pigs).

More thoughts...

If the fitness of a bird is not how many pigs it kills but the variance of pig killings over a range of pig buildings, then a good bird strategy doesn't necessarily maximise the number of pigs killed? Well, yes, it does because increasing the mean will increase the variance of pigs killed typically. However, if we were to allow a greater space of fitness functions for bird strategies then it might be the case that bird strategies can gain fitness not only from variance in the number of pigs killed but e.g. in the number of pigs that survive, or the number of pigs that are pushed into a box, or the number of pigs made to be able to fly, or the number of pigs that stand on each other in a big totem pole of pigs, or the number of pigs touching each other at the end, or maybe not even anything to do with pigs, e.g. the volume of air trapped in a building at the end, etc... So bird strategies may evolve that don't even kill pigs.

Pig strategies will evolve to counter each of the above bird fitness functions, e.g. pig strategies to reduce the number of pigs killed, to increase the number of pigs killed, to reduce the number of pigs pushed into a box, to reduce the number of pigs made to fly, to be very untotumpole like, to not touch at the end, or have no air trapped in the building.

Which of these games is played will depend on the variance of pig strategies on that particular game, because that is the selection criterion for the bird strategies.

So the bird strategies dictate the game, and the pig strategies respond to the bird strategies that survive.


When viewed like this, it seems unnecessarily asymmetrical. What happens if it was the pig strategies that were selected on the variance of bird strategies on the pig games? Would the outcomes be different? Lets simulate it in our brains. OK, so the pig strategies have the same representational language as the bird strategies but are just their opposites, so, yes, I think it would be symmetrical. You just have to assign one population to be selected on the basis of the variance of the fitness in the other population. It doesn't make any sense to make both populations a function of the variance in the fitness of the other population does it? 


Possible arrangements:

1. Let population Gi consist of individuals selected on the basis of maximising the variance of fitness function B in its own sequestered population of solutions Si. The fitness of individuals in Si is the value obtained on the fitness function B specified by the game Gi.

2. So Bollocks.

OK, so thanks to Chris from Vision who I didn't give a biscuit to, the following becomes clear. I am doing a hierarchal co-evolution really. In population A are fitness functions. Along with EACH fitness function comes a population of bird and a population of pig strategies. Each random pair of strategies constitutes the unit over which fitness of the game is assessed. There is co-evolution at the lower level between pig and birds, and hierarchical evolution at the level of fitness functions. There is no conflict here! SIMPLE. Sorry for the confusion everyone :) 




No comments:

Post a Comment