Evolution
Hamlet :Do you see yonder cloud that's almost in shape of a camel? Polonius :By the mass, and 'tis like a camel, indeed. Hamlet :Methinks it is like a weasel.
The evolution exercise, aka as the Weasel program, is a computer simulation illustrating the idea that the evolutionary process is different from pure chance.
We start with a target string, which is conventionally: METHINKS IT IS LIKE A WEASEL.
When the startbutton is pressed, a random string of the same length is generated. From this random string a certain number of mutations are created, a hundred in our case, by changing a small number of random characters of each copy.
This new generation of mutations is then tested against the target string. The mutation that has the most characters in common with the target (by accident), will be chosen to be the parent of the next generation.
Through this process the mutated strings will slowly converge on the target, until at least one of them is exactly the same.
Remember, we create a hundred mutations every generation, so if we get a positive result after, say, 55 generations, then in reality we've generated 5500 randomly altered strings and tested them for convergence.
Target: METHINKS IT IS LIKE A WEASEL
Generation | Result | Distance |
---|