The Weasel Program

This is my JavaScript version of Richard Dawkins' Weasel Program, designed to highlight the difference between natural selection and "dumb chance". This is important, as it is often claimed by creationists that organisms are too complex to have evolved by chance, often citing astronomical probabilities to support their claim. These arguments are based on the misconception that evolution is just random mutation, the equivalent of a monkey banging on a typewriter, hoping to produce the complete works of shakespeare.

As Dawkins pointed out, if we simulated such a monkey on a computer, allowing him only 26 capital letters and a space bar, given the speed of modern computers it would probably take him longer than the age of the universe to come up with even the relatively short phrase from Hamlet: "Methinks it is like a weasel."

Evolution, however, while it does depend on random mutation, also depends on a second component: selection. To model the effect of selection on this metaphor, he suggested a simple program. We start with a random series of letters. In each "generation", these letters produce ten offspring. Each offspring is nearly identical to the parent, except for each letter there is a specific chance that it will randomly change into something else. So far so random: now we have a random string of letters producing more random strings of letters.

Enter the selection. In life, the majority of variations are neutral, a few are positive, and a few are negative - the beauty of natural selection, is that it enriches even the slightest positive variations while eliminating the negative. In our model, at each generation, we compare the offspring to the target - "Methinks it is like a weasel". The one that scores the best will be chosen as the parent for the next generation.

The result is pretty impressive - within a few thousand generations - about a minute with a decent computer - we've reached our target.

M E T H I N K S I T I S L I K E A W E A S E L
Current Score:
Current Generation:
Status:Algorithm Not Set

Set Algorithm and Randomise the Sequence

New Generation

Next 10 Generations

Next 100 Generations