Evolved Art

Computers are thought of as unthinking, logical machines. However, it is still possible, in a way, to ask a computer to create specific kinds of abstract art — sometimes without directly specifying what it should look like.

Genetic algorithms (which I’ve played with before) represent problems to be solved as sequences of bits. For example, an uncompressed RGB bitmap could be represented as 24*X*Y bits, where X and Y are the width and height in pixels of the picture in question. These bits can then be treated as genes — subject to crossover, mutation, and perhaps other operators when creating a new generation.

The key is the fitness function. Each candidate solution is tested to see how well it works. It is assigned a score on some arbitrary scale by the fitness function. A simple fitness function for pictures, for example, might award a positive score for blue and green, and deduct points for red. This would eventually lead to a picture of pure cyan pixels (#00FFFF).

Similarly, an existing picture can be used as a fitness function. As the candidate solutions blindly evolve, selection pressures ensure that more child genomes drift towards the optimal solution (the search space here is linear and smooth.) Eventually, over the generations, the picture emerges.

In the above video, bytecode genomes are interpreted as wire art. Every pair of bytes represents one 16-bit polar coordinate — one of 65,536 equally-spaced points on the unit circle. Two such pairs make a chord; a virtual “wire” can be strung between them, changing pixel values in the area inside the circle.

In this run, a fixed population of 150 genomes of length 1400 (representing 350 wires) are evolving. Each generation, each genome is evaluated in terms of how closely it would match the target image, if interpreted as polar coordinate wire art. Pairs of genomes are chosen at random, and a sort of contest is run. The genome of the two with the higher fitness score is more likely to be chosen to reproduce. In this way, genomes which code for wires that contribute helpful pieces of the target image are selected for.

(Monochrome wire is used in this run, but greyscale and full RGB color are also possible. I’m using monochrome here, since it’s faster.)

The scientific community has known for over a century that Darwinian evolution works. But it’s still fascinating to see it for yourself in real-time.

This entry was posted in BASIC, Coding, Math, Science. Bookmark the permalink.

Leave a Reply