Finding Dawkins’ Weasels

Monkeys, Shakespeare, and 747s

A philosopher once asked if an infinite number of monkeys with typewriters could come up with the works of Shakespeare given an infinite amount of time. The question arises in various forms frequently from critics of the Theory of Evolution. One famous version of this comes from the astronomer Sir Fred Hoyle, who complains that expecting a random process like evolution to produce a living organism is like expecting a tornado moving through a junkyard to assemble a 747 airplane.

A Problem for Evolution?

Evolutionary biologist and author Richard Dawkins addressed this question in his popular book, The Blind Watchmaker, about evolution. Dawkins writes:

The operative phrase is, of course, given enough time. Let us limit the task facing our monkey somewhat. Suppose that he has to produce, not the complete works of Shakespeare but just the short sentence ‘Methinks it is like a weasel‘, and we shall make it relatively easy by giving him a typewriter with a restricted keyboard, one with just the 26 (capital) letters, and a space bar. How long will he take to write this one little sentence?

The number of random combinations of 28 letters is 1040, or 10 followed by 40 zeros. Dawkins then suggests we use a computer to generate the random strings. However, calculations indicate that even this computerized monkey would not be able to complete the task before the universe comes to an end.

Or a Misconception

Dawkins introduces this problem because it represents a common misconception about Evolution. What is missing is the process of cumulative selection. And that makes all the difference. He writes,

We again use our computer monkey, but with a crucial difference in its program. It again begins by choosing a random sequence of 28 letters, just as before … it duplicates it repeatedly, but with a certain chance of random error – ‘mutation’ – in the copying. The computer examines the mutant nonsense phrases, the ‘progeny’ of the original phrase, and chooses the one which, however slightly, most resembles the target phrase, METHINKS IT IS LIKE A WEASEL.

He says that if you repeat the process, each time starting with a slightly better phrase, you can reach the target in a reasonable amount of time. At that particular time, he had an Apple II computer on which he wrote his famous Weasel program in BASIC to demonstrate his point.

My Weasels

I wrote my own version of Weasels in Typescript, which compiles to JavaScript, which can run in your browser.

My version makes the problem slightly more complicated because it uses uppercase and lowercase letters and punctuation. But you have far more computing power in your browser than Dawkins had on his Apple II.

How Does it Work?

So, how does this program work? First, it creates 5000 random strings. Then it does the following steps:

  1. Randomly mutate each string 3 times by
    • Picking a random location in the string.
    • Randomly either deleting the character, inserting a character, or changing the character.
  2. Compare 1 all the strings to the target string.
  3. Choose the string that is closest to the target string.
  4. Make all the other strings like that one.
  5. Repeat all the steps until the best string is the same as the target string.

I would like to point out that step 1, where each string is mutated three times randomly, happens without its consequences on the string. The mutating code does not consult the target string to guide its mutations. It is the first part of what Dawkins calls The Blind Watchmaker.

So, how can it possibly beat those overwhelming odds of finding the target in 1040 combinations? The magic is in the cumulative selection process. In step 3, the closest string out of all the 5000 strings is chosen to be the parent of the next generation. The other 4999 become its children, all inheriting the same characteristics as the parent.

Then, the next pass through all the children involves making a small number of mutations on each one. Then the process repeats. Surely, mutations make many strings worse, some strings end up about the same, and some end up a bit closer to the target.

Each pass yields a closer string, even though the raw material for choosing the following parent string resulted from pure random mutations.

Complaints About Dawkins’ Weasels

Not surprisingly, people from the Intelligent Design community published complaints about Dawkins’ simulations. The first few come from the ID blog site, called Evolution News. Jonathan Witt writes,

First, on its evolutionary journey from gibberish to the line from Shakespeare, the program passes through and builds from utterly dysfunctional intermediates. That’s a problem because the Darwinian process of natural selection tends to eliminate dysfunctional offspring.

Jonathan has not defined what he means by “dysfunctional”. In the simulation, fitness measurement is defined as the degree of similarity between a string and the target string. For demonstration purposes, each new parent string is more fit than the previous one. The string chosen as the parent on each generation is only one of 5000, with the others that are less “close” being eliminated by the selection.

The next objection from Witt is,

Second, the computer simulation has been programmed to aim for a particular distant goal — the weasel line from Hamlet. That’s a problem because Darwinian evolution doesn’t work toward particular distant goals. It isn’t mindful but mindless, not seeing but blind.

This is a reasonable complaint if the Weasel program is supposed to be an evolution simulator. Evolution has no fixed end goal it is working towards. It seeks only to maximize the size of a particular population. But Dawkins was not trying to create an evolution simulator. It was a program designed to demonstrate that a random process, when combined with cumulative selection, could produce something that is not random. It succeeds at that demonstration with a straightforward process.

But even if you insisted that Weasels is an evolution simulator, you have to admit that it goes a very long way in demonstrating the Darwnian process, such as:

  • A population of many instances of the same creature.
  • Each offspring inherits its DNA from its parent, but with some degree of random variation. The random variation occurs without regard to its consequences on the organism.
  • Some selection process evaluates the randomly varied offspring and selects the next parents based on some criteria for “fitness”. It’s only in that last step that the target string is ever consulted. It is, therefore, an exaggeration to say that the program “aims” at the target string. The mutations occur randomly, without regard for the target string.

I’d like you to stay tuned for a follow-up post where I demonstrate a similar program that produces something non-random without a target goal built into it.

  1. Using the Levenshtein distance algorithm. ↩︎

Leave a Comment