My Color Weasel Script


Introduction

Weasel
Weasel

This page contains a JavaScript, which is similar to the ‘My Weasel Script’, but the sentences are used as a genetic code for colors.

One of the criticisms of the Dawkins’ weasel was that the program generates dysfunctional intermediate sentences (gibberish). Well, if you don’t speak English, even the Weasel sentence of Shakespeare is gibberish, but that’s not the point. The reason that the criticism is not justified is that the Weasel sentence is not a phenotype but a genotype. The sentence should be seen as a genetic code, like a string of DNA.

For example, we can let the letters of the text be a code for the color of an animal. All the intermediate sentences are also codes, each for different colors. They are functional, they code for color. Now let’s see if these intermediates show gradual improvement.

This script uses the same algorithm as My Weasel Script. We imagine that the Weasel sentence is a code for the color of an animal that matches a background color (tree bark, leaves, rocks, soil). The other sentences describe the color of an evolving animal that lives near that background. An animal with colors that are closer to the background color will be less visible in its environment. It will be less targeted by predators and it will have a bigger chance of surviving and passing its color genes to the next generation. An animal with the same color as the background will be more or less invisible as it has a perfect camouflage.

The script calculates for each sentence the sum of the Ascii codes of all the letters. The sentence then gets a score, which is the difference with the Weasel sentence. The weasel sentence is the code for a bright green color (imagine the animal to sit on a bright green background color). The computer code for this color is: rgb(0,255,0). The first random sentence, which is the genetic code of the animal that starts the simulation, gets a dark green color: rgb (0,100,0). The score of each intermediate sentence determines its corresponding color. With the sentences becoming closer to each other, we see the color of our animal gradually shifting towards the background color. Selection (by the predator) improves the camouflage of the animal.

Click the ‘Run Weasel’ button to repeat the simulation.

Tip: Hide this introduction text while running the simulations.


Simulation result


Now look at the Peppered Moth Simulation which is another simulation I wrote. The Peppered moth is an insect that has a dark appearance in areas with industrial pollution, where trees are darker because of soot on the bark. In a cleaner environment, with lighter colored tree bark, the moths have a lighter appearance.

Scroll to Top