Project of the week: Genetic Algorithms
So it seems like every other week or so I start work on another little side project that ultimately won’t amount to much but expands my knowledge and abilities. This week, that project was the creation of a genetic algorithm that attempts to recreate images using only 140 colored, translucent circles.
The way it works is it starts out with a base population of 24 random sets of circles and uses a simple image-difference fitness function to determine the “fittest” images, which are then picked and “mated” with each other at random to produce offspring for the next population of 24, along with a clone of the fittest image and a random candidate from the set of “losers”. Some of these circles are also mutated at random, which is of course necessary for new “genetic material” to enter the population. Of course, the objective here is that an increasingly accurate image will gradually “evolve” and since it’s mathematically impossible to have a “correct” solution with only 140 circles, the image will continue “evolving” forever, although I’m sure at some point it will stop being able to progress.
So far, I’ve had some interesting success. The program is still running, and here are the current results (this will be updated every few seconds or so for a while… it’s continually running):
Target Image:

Current Results:

The Code
Only 160 lines of Python
EDIT (12/28/08):
I have stopped the program because it seemed to reach a point where no progress was being made. It seems there is only so much one can do with 140 colored circles.

December 14th, 2008 at 10:57 am
my friends and I played with this back in Prague during our spare time, but could never get it to work.
software like this, when taken fully down its path, could lead to AI. having no computable result or “finish line”, leaving the program to think and decide for itself is an intriguing thought. what if the computations get to a point where the parameters you set conflict with what the algorithm thinks the generated image should be? someday, the software written will be so powerful, it will decide against a chosen parameter, and AI will be born.
December 16th, 2008 at 1:23 am
Good “job” Ryan.
December 17th, 2008 at 3:58 pm
You look sexy sexy in both pics.
December 21st, 2008 at 3:09 pm
nice
December 23rd, 2008 at 5:27 am
ryan, your beard’s lookin a bit circular lately.
December 23rd, 2008 at 5:35 am
Ryan is defintely a well rounded guy and he sure isn’t no square.
January 3rd, 2009 at 8:43 am
I see you’ve decided to ride the genetic algorithms into the new year.
January 29th, 2009 at 8:11 am
[…] The Crumminist Manifesto » Blog Archive » Project of the week … […]
May 12th, 2009 at 5:27 pm
I am constantly dissapointed by this…
September 29th, 2009 at 6:23 pm
Northwestern.