Evolving the Mona Lisa
Welcome! Click start to see genetics in action, as a
randomly generated collection of shapes evolve to resemble
a given picture.
How it Works
This page uses a genetic algorithm to model a population
of individuals, each containing a string of DNA which can
be visualised in the form of an image. By starting with a
population consisting of a randomly generated gene pool,
each individual is compared against the reference image
(the one on the left), and the individuals can then be
ranked by their likeness to it, known as their "fitness",
with the best fit being displayed on the output image (the
one on the right). By breeding the fittest individuals
from the population, the DNA which produces the most
accurate representation of the reference image is selected
over successive generations, effectively demonstrating the
power of a natural selection process to produce the best
candidate for any given environment.
Source Code
As with all good things in life, this was created for fun, free,
and science. The full source code for this site is available on
GitHub
and is released under the terms of the MIT License. If you just want
to see how the genetics algorithm works, you can see the JavaScript
implementation
here.
Bugs and comments
I would love to know what you think. Don't be afraid of
getting in touch with any
thoughts and suggestions. If you would like to be a little more
involved in the process, feel free to fork the
source code repository
and submit a pull request.
Credits
The code is my own, the idea is not. Full credit goes to
Roger Alsing
for the idea of using genetic algorithms to approximate fine
art. Further thanks to
Jacob Seidelin
for writing a JavaScript implementation that inspired me to
create this.