In the Wiki Weasel Script the sentences get a score which depends on the number of correct characters in the right place. In My Weasel Script, the sentences get scored by looking at individual letters. Each letter gets points according to the distance to the correct letter, where ‘distance’ is the distance in the alphabet. So the distance between D and E gives just 1 point, but a distance between A and Z is 25 points.
The script uses ASCII character codes to calculate the distances. ASCCII codes are the numbers 65 to 90 for A to Z, and number 32 for a ‘space’ character.
Instead of aiming at a maximum (28 points is the maximum in the Wiki Weasel algorithm), this script aims for the lowest score, and eventually zero. When all letters match, the score is zero and the script stops.
Why is this method better?
The My Weasel method is better because the intermediate sentences gradually get ‘closer’ to the Weasel sentence. The sentences should be seen as a genetic code, and in each generation the code gets closer to the ‘target’. In the Wiki Weasel method, two intermediate sentences could have the same score (e.g. 2 letters in the correct place) while one of them is much closer than the other. The Wiki Weasel program may fail to pick the best one.
The Wiki Weasel judges each letters as ‘right’ or ‘wrong’, but the My Weasel algorithm can also discriminate between a ‘wrong letter’ being better than another ‘wrong letter’. That this distance matters can be illustrated if we let the sentences be a genetic code for a certain phenotype, for example it could be seen as a code which determines the color of an animal. For this, see ‘My Color Weasel Script‘.
Click the ‘Run My Weasel’ button to repeat the simulation.
Tip: Hide this introduction text while running the simulations.
Now have a look at ‘My Color Weasel Script‘, where the sentences are used as a genetic code for the color of the weasel.