Wednesday, 30 June 2010

Generative Art

Just thought I'd have a quick look at creating some generative art after reading Karl Simms' paper on Artificial Evolution for Computer Graphics. Images are created by randomly acting various functions on a bitmap in some predetermined order. Functions might include gradients, convolution filters, shapes amongst others. At this stage I have only made a black and white version of the generator, but I'll look what I can do about a colour one sometime soon. Just click the first images to launch the app, click and click again to stop/start the generator. If you find some cool images just take a screenshot and email them to me.

Monday, 28 June 2010

Physics Evolution: Step 1

After a bit of a post exam break I'm back to my desk and playing around with some projects that I've had to let lie for some reason or another over the last few months. The first one I thought I'd look at again was the Creature Evolution in Flash article I wrote a few months ago. Back then the idea was to write a program that would evolve creatures using genetic algorithms. Today I've been working on the first step namely creating a world within which these creatures should be able to evolve. This requires a physics engine and instead of writing my own from scratch, or using something I've made before I decided to go with an efficient, fast, and reliable engine, APE, by Alec Cove. You can download the API here.

So I've been getting to grips with the engine which seems fairly simple to use and here is a little demo:

So what is next? The idea behind genetic algorithms is that some genotype, in this case a string of 1's and 0's, determines a phenotype, in this case the structure of a creature. By randomly mutating bits in the genetic code, and testing the resulting creatures against one another, and sticking with the code that yields the best results, creatures can be made to evolve. Creatures can for example be tested for their ability to run fast, or for their ability to jump, or to swim.

Ideally I will reach a stage where code can be saved at any stage of the process, and can be emailed to another person somewhere else in the world who can continue to evolve the same creature. Obviously since evolution is random there could be some very interesting splits. It would be nice to create a sandpit where creatures could be watched. A further investigation would be the effect of mating genotypes to create hybrid creatures, and obviously the nature of the algorithm used to produce creature structure would determine the success of this.

Anyway stay tuned for progress!

Tuesday, 22 June 2010

Von Neumann Cellular Automata

I just saw the TED talk from Stephen Wolfram below and noticed I'd never written any 1D cellular automata. He briefly mentions rule 30 and the emergence of complexity from a simple set of rules. The Von Neumann automata is very simple to write. Given a single cell, the state of the new cell (either on or off) is determined by the cells in its local neighbourhood. In one dimension this means the state of itself, the cell just to its left, and the cell just to its right. This means there are 8 possible states for local neighbourhoods (8 rules) and therefore 256 possible outcomes of the system.

As Mr Wolfram mentions in the talk, most of the outcomes are not particularly interesting, some are very plain and some are quite pretty. Below is rule 26, it looks nice but beyond that it is quite a simple rule. Self repetition on a number of different scales is pretty much all it is capable of. Just click the image to launch it.

The next two examples are rule 30 and rule 110 respectively. These are extremely interesting. Rule 30 displays what Wolfram calls "Class 3" behaviour, which is a chaotic and seemingly random, whereas Rule 110 displays "Class 4" behaviour, which is neither completely random nor completely repetitive. The interaction of various local structures is used to prove Universality. Again just click the images to launch the programs!

Rule 30 can be used as an excellent random generator:

Notice the life-like region travelling up near the centre in Rule 110: