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:
Target Image

Current Results:
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.

10 Responses to “Project of the week: Genetic Algorithms”

  1. JR Says:

    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.

  2. Troy Says:

    Good “job” Ryan.

  3. davidt Says:

    You look sexy sexy in both pics.

  4. Genetic_Algorithm Says:

    nice

  5. rich Says:

    ryan, your beard’s lookin a bit circular lately.

  6. Genetic_Algorithm Says:

    Ryan is defintely a well rounded guy and he sure isn’t no square.

  7. JR Says:

    I see you’ve decided to ride the genetic algorithms into the new year.

  8. Woot! What’s Buzzing Now? » Blog Archive » Indonesian Black America Web Says:

    […] The Crumminist Manifesto » Blog Archive » Project of the week … […]

  9. dthompson Says:

    I am constantly dissapointed by this…

  10. dthompson Says:

    Northwestern.

Leave a Reply