Genetic Algorithms: A Visual Study

2015-03-21





See those pictures above? They are visual examples of a genetic algorithm I've been working on these past few days. *

A generative algorithm simulates ideas found in evolutionary science like breeding, natural selection, and mutation. From a computational standpoint, we can take two sets of data and "breed" them together to create offspring that have a mix of their traits. A number of parents can create a pool offspring. A handful of the most fit offspring are chosen, and they are mated together to create the next generation, and the process begins again. This can happen for generations until the ideal well-bred data set is created.

The visuals I've created demonstrate how two parents can mate to produce children with similar traits. In each row there are three square patterns. From left to right, you have parent A, parent B, and their offspring. The parameters are set so that parent A will have more dominant features in their offspring.

The rules for this algorithm are fairly simple an easy to understand:

  1. An organism is comprised of N cells. 2. Every cell can have one of 4 states. 3. Two organisms with the same number cells can mate. 4. Mating two organisms involves taking the states of the corresponding cells of each organism, and applying an operation to create a new cell with a state. 5. One of four operations can occur and are chosen randomly.
  2. These operations are as follows: A=choose the state of parent A, B=choose the state of parent B, M=choose a state that is neither in parent A or B, and W= choose any state at random.

In my visual examples, I using organisms with a size of 64, whose states are color coded. These pictures are flipped on the vertical and horizontal axis in order to be more aesthetically pleasing.

I've been very excited about the visual results so far. The idea of taking two creative ideas and blending them together is quite attractive to me. As a sound designer, I'm more curious as to how this algorithm can be applied to synthesize sounds. If all goes well, this will probably snowball into a new musical composition of sorts.

*For those wondering, the algorithm was written in C, and a combination of Perl and Imagemagick, and shell scripts were used to create the visuals.