Dawkins Weasel Remix
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Dawkins Weasel 1.1.0
WHAT IS IT?
Dawkins Weasel is a NetLogo model that illustrates the principle of evolution by natural selection. It is inspired by a thought experiment presented by Richard Dawkins in his book The Blind Watchmaker (1986). He presents the idea as follows:
"I don't know who it was who first pointed out that, given enough time, a monkey bashing away at random on a typewriter could produce all the works of Shakespeare. 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?"
He goes on to point out that - by random mechanisms alone - a monkey is unlikely to produce the phrase in any reasonable amount of time:
"To put it mildly, the phrase we seek would be a long time coming, to say nothing of the complete works of Shakespeare."
However, Dawkins points out, with selection the problem becomes quite manageable:
"What about cumulative selection; how much more effective should this be? Very very much more effective, perhaps more so than we at first realize, although it is almost obvious when we reflect further. 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: 'WDLMNLT DTJBKWIRZREZLMQCO P'. It now 'breeds from' this random phrase. 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'."
Dawkins Weasel is a model of this thought experiment, demonstrating the effectiveness of selection for rapidely producing a given target phrase.
HOW TO USE IT
Settings
Write in the TARGET-PHRASE input box to determine the target phrase for your simulation.
Use the MUTATION-RATE slider to determine the rate at which each character in a string mutates. The higher the mutation rate, the more likely that each character present in the parent string will produce an error - mutation - in its offspring.
Write in the NUMBER-OF-OFFSPRING input box to determine how many offspring each parent string will produce for every generation.
Use the WITH-SELECTION switch to decide whether your simulation will include selection or not. Without selection, you are simulating a monkey typing on a keyboard, causing random changes to the string. With selection, you are simulating cumulative selection, as described by Dawkins above.
Buttons
Press SETUP after all of the settings have been chosen. This will initialize the program to create a random string to serve as the initial ancestral state.
Press GO-ONCE to produce the parent string for the next generation, which is selected because it is the closest match to the TARGET PHRASE.
Press GO to make the simulation run continuously. This will create new generations of strings indefinitely or until it matches the TARGET PHRASE. To stop the simulation, press the GO button again.
Output
While it is running, the simulation will print out the results from each generation, which provides the current generation number and the closest matching string of that generation. For example:
20 ZETHINKS IT AS LIKW A WEABEL
If/When the simulation produces a string that completely matches the TARGET-PHRASE, the simulation will stop and print out the results of this simulation in the COMMAND-CENTER box.
THINGS TO NOTICE
The purpose of this model is to demonstrate that natural selection is different than accumulated changes occuring by pure chance. Pay attention to how the settings affect the rate at which the simulation produces the TARGET PHRASE:
- What MUTATION RATE(s) produce the most or least rapid effects?
- How does the NUMBER OF OFFSPRING affect this rate?
- Does it matter how long the TARGET PHRASE is?
- Which is more effective: with selection or without selection?
REFERENCES
Dawkins, R. 1996. The Blind Watchmaker. New York, NY, W. W. Norton & Co.
HOW TO CITE
Crouse, Kristin (2020). “Dawkins Weasel” (Version 1.1.0). CoMSES Computational Model Library. Retrieved from: https://www.comses.net/codebases/6042/releases/1.1.0/
COPYRIGHT AND LICENSE
© 2020 K N Crouse
This model was created at the University of Minnesota as part of a series of models to illustrate principles in biological evolution.
The model may be freely used, modified and redistributed provided this copyright is included and the resulting models are not used for profit.
Contact K N Crouse at crou0048@umn.edu if you have questions about its use.
Comments and Questions
globals [ uppercase lowercase parent-string generation all-done ] to setup clear-all set uppercase "ABCDEFGHIJKLMNOPQRSTUVWXYZ " set lowercase "abcdefghijklmnopqrstuvwxyz" setup-intial-string initialize-string set generation 0 set all-done false reset-ticks end to go if all-done [ stop ] ; this line prevents the simulation from continuing to print out the following at every timestep after completion: if (with-selection and go-with-selection = 0 ) or (not with-selection and go-without-selection = 0) [ ; simulation found an exact matching phrase set all-done true print word "It took " word generation word " generations of " word number-of-offspring " offspring to evolve to the target phrase." stop ] tick end to output-generation output-print (word generation " " parent-string) end to-report go-with-selection ; go function used when WITH-SELECTION is TRUE let offspring-string parent-string let top-offspring-string parent-string let top-offspring-score get-score parent-string let uppercase-length length uppercase let string-length length parent-string set generation generation + 1 let i 0 ; EACH OFFSPRING LOOP while [i < number-of-offspring] [ set offspring-string parent-string; let j 0 ; EACH CHARACTER LOOP while [j < string-length] [ let mutation-probability random-float 1.0 if mutation-probability < mutation-rate [ let random-letter item (random uppercase-length) uppercase set offspring-string replace-item j offspring-string random-letter ] set j j + 1 ] ; compares current offspring with top offspring let current-offspring-score get-score offspring-string if current-offspring-score < top-offspring-score [ set top-offspring-string offspring-string set top-offspring-score current-offspring-score ] set i i + 1 ] set parent-string top-offspring-string output-generation report top-offspring-score end to-report go-without-selection ; go function used when WITH-SELECTION is FALSE let uppercase-length length uppercase set generation generation + 1 let i 0 while [i < length parent-string] [ let mutation-probability random-float 1.0 if mutation-probability < mutation-rate [ let random-letter item (random uppercase-length) uppercase set parent-string replace-item i parent-string random-letter ] set i i + 1 ] output-generation report get-score parent-string end to setup-intial-string let string-length length target-phrase if string-length < 1 [ set target-phrase "SORRY DAVE I CANNOT ALLOW THAT" ] let i 0 while [i < string-length] ; replace lowercase with uppercase: [ if (not member? item i target-phrase uppercase) [ ifelse (member? item i target-phrase lowercase) [ set target-phrase replace-item i target-phrase item (position (item i target-phrase) lowercase) uppercase ] [ set target-phrase replace-item i target-phrase " " ] ] set i i + 1 ] end to initialize-string let initial-string target-phrase let string-length length initial-string let uppercase-length length uppercase let index 0 while [index < string-length] [ let random-letter item (random uppercase-length) uppercase set initial-string replace-item index initial-string random-letter set index index + 1 ] set parent-string initial-string; set parent-string initial-string output-generation end to-report get-score [input-string] ; score used to determine how well the INPUT-STRING matches the TARGET-PHRASE let string-length length input-string let score string-length let index 0 while [index < string-length] [ let goal-letter item index target-phrase let input-letter item index input-string if goal-letter = input-letter [set score score - 1] set index index + 1 ] report score end
There is only one version of this model, created over 2 years ago by Evgeny Patarakin.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Dawkins Weasel Remix.png | preview | Preview for 'Dawkins Weasel Remix' | over 2 years ago, by Evgeny Patarakin | Download |
This model does not have any ancestors.
This model does not have any descendants.