
A genetic algorithm provides a simple way to search for an approximately optimal solution for an otherwise difficult and complex problem. By simulating the process of evolution, random mutation, breeding and selective pressure, a program can evolve a solution to a problem.
Seth Just wrote in with a simple and customizable genetic algorithm written in Perl. Given a problem set, you can define a function to randomly initialize each “individual”, a mutation function to alter an individual, a breeding function that combines individuals with the strongest members, and a fitness function that computes the strength of an individual. His code is well documented and you can adapt it for your own problems fairly easily.
He also points us to a couple of interesting projects that are worth mentioning. The evolution of the Mona Lisa, pictured above, is an example genetic algorithm written by Roger Alsing. Given only 50 semi-transparent polygons and over 900 thousand mutations, his program is able to optimize their placement and color to produce an incredible likeness of the Mona Lisa.

Another cool example is this Flash vehicle simulator. A car with two wheels and two passengers is randomly constructed and its fitness is defined by how far it is able to drive without the passengers touching the ground. At first, most iterations don’t even get past go, but as the evolution proceeds, a more robust vehicle is formed which is capable of navigating the terrain.
Genetic Algorithms in Perl
Genetic Programming: Evolution of Mona Lisa
Genetic Car










Has anyone else checked this genetic car out and just stared at it for hours? I am really curious how it works. Does each car only get to drive for a sent amount of time? Which variables are changed and how can I track the changes?
@Moldy When ever the dotted red circle touches the ground it reiterates
The Mona Lisa one reminds me of something I hacked up once:
http://www.soe.ucsc.edu/~mds/genetic_trees/
Never did quite get it to do what I wanted — but it worked great on synthetic data.
// What's Trending
Raspberry Pi Design Contest
Dad Builds Son an Iron Man Arc Reactor
Teardrop Camper Trailer
Seventeen Sneaky Secret Hides
What to do with an 800 Lb Eucalyptus Slab
10 Things to Connect to Your Raspberry Pi
3D Printed Kinetic iPhone Cases
// What's Shared
A better way to slice a pumpkin
DIY Nerf Darts
100 Dollar Store Organization Ideas for Craft Rooms and Beyond
In the Maker Shed: Minty Boost USB Charger
Mad’s Mouse House
Lace Princess Crowns
I Have a (Puzzling) Dream
Play the Rings of a Tree Trunk Like a Record
// Most Commented
Plastic Bags into Plastic Blocks: Revisited
10 Hot New Boards to Watch
Why the Maker Movement is Here to Stay
MAKE Asks: Roadside Hacks
DIY Hacks & How To’s: Convert From Battery Power to AC
Ten Tips for Hand Saws and Blades
How To Make Your Own Laundry Detergent
What to do with an 800 Lb Eucalyptus Slab