Author Topic: Methinks It Is Like A Weasel - An Evolutionary Program  (Read 4576 times)

0 Members and 1 Guest are viewing this topic.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Methinks It Is Like A Weasel - An Evolutionary Program
« on: August 11, 2019, 10:24:10 am »
Hamlet thinks that Polonius is a fool, which he demonstrates in the following conversation:

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."
Polonius: "It is backed like a weasel."
Hamlet: "Or like a whale?"
Polonius: "Very like a whale.”


You will be very familiar with Richard Dawkins (ethologist and evolutionary biologist) and his expositions of evolution which are always completely proof against any counter-argument.  In one of his books "The Blind Watchmaker" he describes his attempts to demonstrate natural selection by mutation and survival of the fittest by creating a computer program.  See the Wikipedia URL for detailed information.
https://en.wikipedia.org/wiki/Weasel_program

His computer program simulates an analogous process by attempting to create the phrase "Methinks It Is Like A Weasel" from a starting string block of random letters.  At some point in each of our lives there is probably a desire to write our own "Methinks It Is Like A Weasel" program, so this is my attempt (program updated 15/8/19 for more realistic probabilities, error removal and tidied).
Code: QB64: [Select]
  1. 'METHINKS IT IS LIKE A WEASEL by QWERKEY 15/8/19
  2.  
  3. '128 Males + 128 Females
  4. '128*Birthrate Male Offspring + 128*Birthrate Female Offspring: Male Odd-recessive, Female Even-recessive
  5. 'A certain percentage of mutations in the offspring
  6. 'Only the most adapted 128 Male and 128 Female Offspring survive
  7. 'As Methinks2 (tidied up) but with immovable correct gene removed, mutation rate much reduced, and errors corrected
  8.  
  9. CONST True = -1, False = 0
  10. CONST NoMates% = 128, NoIssue% = 141, JumpStart% = 256, MutationRate! = 2 / 1000
  11. CONST Elite! = 3 / 7, Kappa! = 4, Prob0! = 0.23, GenLimit% = 30000
  12. DIM Mates$(NoMates% - 1, 1), MatesDat%(NoMates% - 1, 1), IssueDat%(NoIssue% - 1, 1)
  13. DIM Mating%%(NoMates% - 1)
  14.  
  15. _TITLE "Methinks It Is Like A Weasel"
  16. Weasel$ = "METHINKS[IT[IS[LIKE[A[WEASEL"
  17. Alphabet$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ["
  18.  
  19. SCREEN _NEWIMAGE(984, 720, 32)
  20.  
  21. 'Initialise 1st Generation
  22. Generation% = 1
  23. FOR R%% = 0 TO 1
  24.     FOR N%% = 0 TO NoMates% - 1
  25.         Mates$(N%%, R%%) = MID$(Alphabet$, INT(RND * 26) + 1, 1)
  26.         FOR M%% = 2 TO 28
  27.             Mates$(N%%, R%%) = Mates$(N%%, R%%) + MID$(Alphabet$, INT(RND * 27) + 1, 1)
  28.         NEXT M%%
  29.         MatesDat%(N%%, R%%) = 0
  30.         FOR M%% = 1 TO 28
  31.             MatesDat%(N%%, R%%) = MatesDat%(N%%, R%%) + ABS(ASC(MID$(Weasel$, M%%, 1)) - ASC(MID$(Mates$(N%%, R%%), M%%, 1)))
  32.         NEXT M%%
  33.     NEXT N%%
  34. NEXT R%%
  35. 'Sort & Display 1st Generation
  36. CALL Sort1(MatesDat%(), Mates$())
  37.  
  38. 'Cycle through generations:
  39. REDIM Papa%%(NoIssue% - 1, 1)
  40. Dawkins%% = True
  41. OneByOne%% = True
  42. WHILE Dawkins%% AND Generation% < GenLimit%
  43.     'Display Current Generation
  44.     CLS
  45.     COLOR _RGB32(255, 255, 255)
  46.     _PRINTSTRING (4, 4), "Generation:"
  47.     _PRINTSTRING (92, 4), STR$(Generation%)
  48.     _PRINTSTRING (186, 4), "(" + LTRIM$(STR$(MatesDat%(0, 0))) + ")"
  49.     FOR R%% = 0 TO 1
  50.         IF R%% = 0 THEN
  51.             COLOR _RGB32(255, 255, 0)
  52.         ELSE
  53.             COLOR _RGB32(0, 255, 255)
  54.         END IF
  55.         FOR N%% = 0 TO NoMates% - 1
  56.             W$ = Mates$(N%%, R%%) 'W$ gets modified by Spaced$()
  57.             IF N%% <= 63 THEN
  58.                 _PRINTSTRING (4 + R%% * 500, 15 + N%% * 11), Spaced$(W$)
  59.             ELSE
  60.                 _PRINTSTRING (4 + 250 + R%% * 500, 15 + (N%% - 64) * 11), Spaced$(W$)
  61.             END IF
  62.         NEXT N%%
  63.     NEXT R%%
  64.     IF NOT OneByOne%% THEN
  65.         _LIMIT 6
  66.         _DISPLAY
  67.     END IF
  68.     'Find partners (monogamous, brother & sister not allowed to mate)
  69.     PartnersAvailable%% = False
  70.     WHILE NOT PartnersAvailable%%
  71.         PartnersAvailable%% = True
  72.         REDIM Mated%%(NoMates% - 1)
  73.         FOR N%% = 0 TO NoMates% - 1
  74.             CanMate%% = False
  75.             NoTries% = 0
  76.             WHILE NOT CanMate%%
  77.                 IF N%% <= 63 THEN
  78.                     N1%% = INT(RND * NoMates% / 2)
  79.                     IF RND <= Elite! THEN N1%% = N1%% + 64
  80.                 ELSE
  81.                     N1%% = INT(RND * NoMates%)
  82.                 END IF
  83.                 NoTries% = NoTries% + 1
  84.                 IF NOT Mated%%(N1%%) AND (Papa%%(N%%, 0) <> Papa%%(N1%%, 1) OR Generation% = 1) THEN 'By this time, Papa%% has been re-ordered
  85.                     Mated%%(N1%%) = True
  86.                     Mating%%(N%%) = N1%%
  87.                     CanMate%% = True
  88.                 END IF
  89.                 IF NoTries% >= 1200 THEN
  90.                     CanMate%% = True
  91.                     PartnersAvailable%% = False
  92.                     EXIT FOR
  93.                 END IF
  94.             WEND
  95.         NEXT N%%
  96.     WEND
  97.     'Produce Children (always 1 male & 1 female offspring at the same time)
  98.     REDIM Issue$(NoIssue% - 1, 1), Papa%%(NoIssue% - 1, 1)
  99.     NoKidsLess1% = 0
  100.     N%% = 0
  101.     WHILE NoKidsLess1% <= NoIssue% - 1
  102.         IF RND <= (Prob0! + ((Prob0! * N%% * (1 - Kappa!)) / ((NoMates%% - 1) * Kappa!))) THEN
  103.             FOR R%% = 0 TO 1 'Male/Female Offspring
  104.                 FOR M%% = 1 TO 28
  105.                     IF RND < MutationRate! THEN
  106.                         IF M%% = 1 THEN
  107.                             Issue$(NoKidsLess1%, R%%) = MID$(Alphabet$, INT(RND * 26) + 1, 1)
  108.                         ELSE
  109.                             Issue$(NoKidsLess1%, R%%) = Issue$(NoKidsLess1%, R%%) + MID$(Alphabet$, INT(RND * 27) + 1, 1)
  110.                         END IF
  111.                     ELSEIF M%% MOD 2 = 0 THEN
  112.                         Issue$(NoKidsLess1%, R%%) = Issue$(NoKidsLess1%, R%%) + MID$(Mates$(N%%, 0), M%%, 1) 'From father
  113.                     ELSE
  114.                         Issue$(NoKidsLess1%, R%%) = Issue$(NoKidsLess1%, R%%) + MID$(Mates$(Mating%%(N%%), 1), M%%, 1) 'From mother
  115.                     END IF
  116.                 NEXT M%%
  117.                 IssueDat%(NoKidsLess1%, R%%) = 0
  118.                 FOR M%% = 1 TO 28
  119.                     IssueDat%(NoKidsLess1%, R%%) = IssueDat%(NoKidsLess1%, R%%) + ABS(ASC(MID$(Weasel$, M%%, 1)) - ASC(MID$(Issue$(NoKidsLess1%, R%%), M%%, 1)))
  120.                 NEXT M%%
  121.                 Papa%%(NoKidsLess1%, R%%) = N%%
  122.             NEXT R%%
  123.             NoKidsLess1% = NoKidsLess1% + 1
  124.         END IF
  125.         IF N%% = NoMates%% - 1 THEN
  126.             N%% = 0
  127.         ELSE
  128.             N%% = N%% + 1
  129.         END IF
  130.     WEND
  131.     IF OneByOne%% THEN
  132.         'Delay
  133.         _DELAY 1.5
  134.         'Display Childless Parents
  135.         FOR N%% = 0 TO NoMates% - 1 'N%% is the father
  136.             Progeny%% = False
  137.             T% = 0 'T% is the child
  138.             WHILE NOT Progeny%% AND T% <= NoIssue% - 1
  139.                 IF Papa%%(T%, 0) = N%% THEN Progeny%% = True
  140.                 T% = T% + 1
  141.             WEND
  142.             IF NOT Progeny%% THEN
  143.                 COLOR _RGB32(127, 127, 0)
  144.                 W$ = Mates$(N%%, 0) 'W$ gets modified by Spaced$() - don't actually need this substitution here, as updated below
  145.                 IF N%% <= 63 THEN
  146.                     _PRINTSTRING (4, 15 + N%% * 11), Spaced$(W$)
  147.                 ELSE
  148.                     _PRINTSTRING (4 + 250, 15 + (N%% - 64) * 11), Spaced$(W$)
  149.                 END IF
  150.                 COLOR _RGB32(0, 127, 127)
  151.                 N2%% = Mating%%(N%%)
  152.                 W$ = Mates$(N2%%, 1) 'W$ gets modified by Spaced$() - don't actually need this substitution here, as updated below
  153.                 IF N2%% <= 63 THEN
  154.                     _PRINTSTRING (4 + 500, 15 + N2%% * 11), Spaced$(W$)
  155.                 ELSE
  156.                     _PRINTSTRING (4 + 250 + 500, 15 + (N2%% - 64) * 11), Spaced$(W$)
  157.                 END IF
  158.             END IF
  159.         NEXT N%%
  160.         'Use up keypresses & wait for keypress
  161.         _KEYCLEAR
  162.         SetAwhile%% = True
  163.         WHILE SetAwhile%%
  164.             _LIMIT 30
  165.             K% = _KEYHIT
  166.             SELECT CASE K%
  167.                 CASE 32
  168.                     SetAwhile%% = False
  169.                 CASE 27
  170.                     SetAwhile%% = False
  171.                     Dawkins%% = False
  172.                 CASE 102
  173.                     OneByOne%% = False
  174.                     SetAwhile%% = False
  175.             END SELECT
  176.         WEND
  177.     ELSE
  178.         K% = _KEYHIT
  179.         SELECT CASE K%
  180.             CASE 102
  181.                 OneByOne%% = True
  182.                 _AUTODISPLAY
  183.             CASE 27
  184.                 Dawkins%% = False
  185.         END SELECT
  186.     END IF
  187.     IF Dawkins%% THEN
  188.         ' Order children & set new generation
  189.         CALL Sort2(IssueDat%(), Issue$(), Papa%%())
  190.         FOR R%% = 0 TO 1
  191.             FOR N%% = 0 TO NoMates%% - 1
  192.                 Mates$(N%%, R%%) = Issue$(N%%, R%%)
  193.                 MatesDat%(N%%, R%%) = 0
  194.                 FOR M%% = 1 TO 28
  195.                     MatesDat%(N%%, R%%) = MatesDat%(N%%, R%%) + ABS(ASC(MID$(Weasel$, M%%, 1)) - ASC(MID$(Mates$(N%%, R%%), M%%, 1)))
  196.                 NEXT M%%
  197.             NEXT N%%
  198.         NEXT R%%
  199.         RANDOMIZE (TIMER)
  200.         Generation% = Generation% + 1
  201.     END IF
  202.     'IF NOT OneByOne%% THEN _DISPLAY
  203.  
  204. IF Generation% = GenLimit% THEN
  205.     CLS
  206.     _FONT 16
  207.     PRINT "Generation Limit Reached"
  208.     _KEYCLEAR
  209.     WHILE INKEY$ = ""
  210.         _LIMIT 30
  211.     WEND
  212.  
  213.  
  214. FUNCTION Spaced$ (X$)
  215.     I%% = INSTR(X$, "[")
  216.     WHILE I%% > 0
  217.         MID$(X$, I%%, 1) = " "
  218.         I%% = INSTR(X$, "[")
  219.     WEND
  220.     Spaced$ = X$
  221.  
  222. SUB Sort1 (Numbers%(), Names$())
  223.     FOR R%% = 0 TO 1
  224.         Jump% = JumpStart%
  225.         WHILE Jump% > 1
  226.             Jump% = (Jump% - 1) \ 2
  227.             Finished% = False
  228.             WHILE NOT Finished%
  229.                 Finished% = True
  230.                 FOR Upper% = 1 TO NoMates% - Jump%
  231.                     Lower% = Upper% + Jump%
  232.                     IF Numbers%(Upper% - 1, R%%) > Numbers%(Lower% - 1, R%%) THEN
  233.                         SWAP Names$(Upper% - 1, R%%), Names$(Lower% - 1, R%%)
  234.                         SWAP Numbers%(Upper% - 1, R%%), Numbers%(Lower% - 1, R%%)
  235.                         Finished% = False
  236.                     END IF
  237.                 NEXT Upper%
  238.             WEND
  239.         WEND
  240.     NEXT R%%
  241.  
  242. SUB Sort2 (Numbers%(), Names$(), WhosTheDaddy%%())
  243.     FOR R%% = 0 TO 1
  244.         Jump% = JumpStart%
  245.         WHILE Jump% > 1
  246.             Jump% = (Jump% - 1) \ 2
  247.             Finished% = False
  248.             WHILE NOT Finished%
  249.                 Finished% = True
  250.                 FOR Upper% = 1 TO NoIssue% - Jump%
  251.                     Lower% = Upper% + Jump%
  252.                     IF Numbers%(Upper% - 1, R%%) > Numbers%(Lower% - 1, R%%) THEN
  253.                         SWAP Names$(Upper% - 1, R%%), Names$(Lower% - 1, R%%)
  254.                         SWAP Numbers%(Upper% - 1, R%%), Numbers%(Lower% - 1, R%%)
  255.                         SWAP WhosTheDaddy%%(Upper% - 1, R%%), WhosTheDaddy%%(Lower% - 1, R%%)
  256.                         Finished% = False
  257.                     END IF
  258.                 NEXT Upper%
  259.             WEND
  260.         WEND
  261.     NEXT R%%
  262.  
  263.  

The assumptions/conditions in the program are as follows:

  • Each generation has 128 males and 128 females who mate monogamously with a birthrate of 2.2 children (on average!).
  • Each male and female of the first generation starts with a "gene sequence" defined by a 28-character string of random letters from "A" to "Z" (capitals only) and the Space character.
  • The fitness-for-use criterion is defined by how close each character is to same-position character in the phrase "METHINKS IT IS LIKE A WEASEL".
  • Each child inherits half its "genes" from the father and half from the mother.  Male parents are odd-numbered "gene-recessive", whilst female parents are even-numbered recessive.  Thus if the "DNA" were three characters long and the father was XYX and the mother YZY, the child would be YYY.  At each breeding, one male and one female offspring are produced.  Male and female offspring have the same genes as each other, except for the mutations.
  • At each stage there is a chance (0.2% in this case) of gene mutation where a random character is produced in place of the inherited character.  This mutation rate is still much higher than in the biological case.
  • Brother and sister may not mate (we are not only simulating superior genetics, but are also completely morally sound).
  • The mate desirability is higher for the top half of the population.  (There is a 4:3 probability of top-half males selecting top-half females).
  • For each 128/128 male/female generation, the top father has a 4-times probability of reproduction compared to that of the bottom pair.
  • Of the 141 male & female offspring, only the top 128 survive to the next generation.


Run the program as follows:

The display shows two groups of 128 parents, "males" in yellow and "females" in cyan, each in two columns.  They are shown in fitness-for-use order (highest at the top).  The 64 highest are in the left-hand column, with the 64 lowest at the right.

After a short delay, the parents who fail to breed successfully are shown darkened.  The program will wait for a Spacebar press to proceed to the next generation.  You can cycle through the generations in this way.  You will see that the most poorly fit-for-use parents are most likely not to reproduce.

Evolution proceeds quite slowly and you will very soon want to speed things up.  Pressing "f" instead of the Spacebar will then quickly cycle through the generations.  Pressing "f" will revert to the one-by-one generation display.  Esc at any time quits the program.

You will see that about 3000 generations are required to produce a population in which all 256 individuals have the desired gene sequence (this takes about 10 minutes).  This is despite the fact that gene evolution is quite heavily biassed in favour of the desired result.  This is because of the presence in the population of such a large gene diversity.  You will also notice that the likelihood of gene changes falls as the population gets closer to the final result.  This is because any mutation tends to be quickly bred out by the extant majority.  In Dawkins's program, he obtains the final result in 47 generations.  I believe that this is so because his had a simpler procedure and less overall gene diversity.

I apologise for the slight bias in favour of the male sex, both in the coding and in this discussion.  No matter how we try, sexism is difficulty to battle.

Of course, Dawkins was quite aware that writing a program to head towards a known result does not describe how biology works, and the program here is a just-for-fun exercise.

This is my contribution to the demonstration of selection by fitness-for-use.  Please contribute your own program if you care to, describing what assumptions are made and how many generations it takes to produce the final population result.  Methinks it could be fun for you too.
« Last Edit: August 15, 2019, 11:07:06 am by Qwerkey »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Methinks It Is Like A Weasel - An Evolutionary Program
« Reply #1 on: August 15, 2019, 10:55:43 am »
Hi Qwerkey,

Very interesting topic, despite your efforts to keep it light, I can't help wondering seriously, maybe philosophically, how much morality contributes to fitness... well maybe that's better topic for another forum, still it'd be nice to test something with code.

Program wise, I don't like your fitness criteria, and toy with idea for mod or make over. To me, either the letter is right and in the right place or it is no good. So selection would be a test how many letters in the right place. Need a backstory explaining how letters in right place contributes to fitness and that should round out the code for the app / experiment. Like everyone, no matter their genetic makeup are attracted to the ones who have highest letter match counts, such that not just sexual attraction but the high match counts get all the best jobs, food, shelter... cars! So they spread their jeans everywhere in the land of weasel likers and have resources to support offspring (assuming they were a little moral and own up to their non-monogamous habits).

So the code mods would be about the high matchers mobility and getting every advantage, low matchers stuck where they are unattractive, sickly and low birthrates and survival rates...
« Last Edit: August 15, 2019, 11:04:09 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Methinks It Is Like A Weasel - An Evolutionary Program
« Reply #2 on: August 15, 2019, 02:52:38 pm »
Here is an implementation of the algorithm outlined in Wiki (same fitness test I prefer):
Code: QB64: [Select]
  1. _TITLE "Quick Dawking" '  B+ 2019-08-15
  2. 'Pursing Qwerkey's link from Wiki:
  3. '   Although Dawkins did not provide the source code for his program, a "Weasel" style algorithm could run as follows.
  4. '   Start with a random string of 28 characters.
  5. '   Make 100 copies of the string (reproduce).
  6. '   For each character in each of the 100 copies, with a probability of 5%, replace (mutate) the character with a new random character.
  7. '   Compare each new string with the target string "METHINKS IT IS LIKE A WEASEL", and give each a score (the number of letters in the string that are correct and in the correct position).
  8. '   If any of the new strings has a perfect score (28), halt. Otherwise, take the highest scoring string, and go to step 2.
  9.  
  10. CONST target = "METHINKS IT IS LIKE A WEASEL"
  11. CONST Genes = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " 'we could match counts of occurance with number of genes eg 3 Es, 1M, 2 Ts  and just go for odering
  12. DIM i AS INTEGER, j AS INTEGER, Rstring$, eve$, nGeberation AS LONG, bestMutant$, bestMatchCnt AS INTEGER
  13.  
  14. 'geberate random string
  15. FOR i = 1 TO 28
  16.     Rstring$ = Rstring$ + MID$(Genes, INT(RND * 27) + 1, 1)
  17. 'Rstring$ = "HEY QWERKEY SHOULDA USED RND"
  18.  
  19. eve$ = Rstring$
  20. DIM copies(99) AS STRING
  21.  
  22.     'initialize
  23.     FOR i = 0 TO 99
  24.         copies(i) = Rstring$
  25.     NEXT
  26.     'geberate
  27.     FOR i = 1 TO 99
  28.         FOR j = 1 TO 28
  29.             IF RND < .05 THEN
  30.  
  31.                 ''don't mutate fit genes, this makes thing go really fast, no but cuts generations by half approx
  32.                 'IF MID$(copies(i), j, 1) <> MID$(target$, j, 1) THEN
  33.                 '    MID$(copies(i), j, 1) = MID$(Genes, INT(RND * 27) + 1, 1)
  34.                 'END IF
  35.  
  36.                 ''mutate good gene or not,
  37.                 MID$(copies(i), j, 1) = MID$(Genes, INT(RND * 27) + 1, 1)
  38.                 ''not much difference because of the way the rest of this program goes
  39.  
  40.             END IF
  41.         NEXT
  42.     NEXT
  43.     nGeberation = nGeberation + 1
  44.     'select from geberation
  45.     bestMutant$ = copies(0): bestMatchCnt = nMatches(copies(0))
  46.     FOR i = 1 TO 99
  47.         IF nMatches(copies(i)) > bestMatchCnt THEN bestMutant$ = copies(i)
  48.     NEXT
  49.     Rstring$ = bestMutant$
  50.     CLS: PRINT nGeberation, Rstring$
  51.     _LIMIT 60
  52. LOOP UNTIL bestMutant$ = target
  53. PRINT "From "; eve$; " to "; target; " in "; nGeberation; " generations."
  54.  
  55. FUNCTION nMatches (s$)
  56.     DIM i AS INTEGER, n AS INTEGER
  57.     FOR i = 1 TO 28
  58.         IF MID$(target, i, 1) = MID$(s$, i, 1) THEN n = n + 1
  59.     NEXT
  60.     nMatches = n
  61.  
  62.  

Don't have to take lunch waiting for this to finish it's run, you wont even make it out the door!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Methinks It Is Like A Weasel - An Evolutionary Program
« Reply #3 on: August 16, 2019, 04:43:41 am »
bplus, thanks for the implementation of Dawkins's algorithm for completeness.  I'd have thought that he would have provided his code to Rosetta or wherever, but presumably he wrote it so long ago and never kept it (or more likely thought it trivial in his terms).

Very interesting topic

Well, I thought so, and thought that others might create their own unique code and show us what happens.  But it looks like we're keeping this topic to ourselves.  You mention that mine has elements which are not very "gene-like".  But we must remember that what we're doing is simple mathematics, comparison and random number generation, not a simulation of biology.  Although my text is sprinkled with biological terms, it was just done to maintain the degree of "lightness"  which you spotted.

how much morality contributes to fitness...

That would be a difficult project!  Where would one start?  It is much beyond Darwinian evolution* which does lend itself to such simple analogues as we have done here.  Going into civilisation is something else completely.  Remember the fools who, having heard of Dawkins's term "The Selfish Gene", thought that this meant that it was a good and natural thing to be selfish?

*  It remains a wonder that Darwin (and others at the time) came up with the idea even though they had no knowledge of what a gene is.  And then the chemistry of biology gives exactly how Darwinian evolution works.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Methinks It Is Like A Weasel - An Evolutionary Program
« Reply #4 on: August 16, 2019, 09:25:29 am »
Hi Qwerkey,

Ha! I just noticed how close in spelling Dawkins and Darwin are! 4 matches and w is only in wrong place out for 5 of first 6 letters.
I bet Dawkins might have noticed too! Maybe created extra sympathy for Darwin early on in his development.

You say, "You mention that mine has elements which are not very "gene-like".
I only objected to your fitness criteria, genes that are right but in wrong order is like having the perfect nose but exactly where an ear should go or like with code, if your file is off 1 byte, it is likely corrupted, close only counts in horse shoes (and grenades) as they say. 

Don't get me wrong, I do appreciate the effort you made to simulate reproduction / regeneration and kept code around 300 lines, nice job.

Since we are likely to get nowhere testing ideas of morality, I am toying with idea of mutating 9 digit number strings to solve Sudoku puzzles, to mutate you only swap gene / digit positions, so every string starts, right out of the gate, with the right stuff, then, just a matter of getting it in the right order for proper fitness. So far this idea has me planning a possible redesign of my Sudoku worksheet app. Use genetic mutation for solving Sudoku puzzles, how practical is that! (Maybe I have been playing too much word Scrambler lately ;-))
« Last Edit: August 16, 2019, 09:27:36 am by bplus »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Methinks It Is Like A Weasel - An Evolutionary Program
« Reply #5 on: August 16, 2019, 09:56:29 am »
I am toying with idea of mutating 9 digit number strings to solve Sudoku puzzles, to mutate you only swap gene / digit positions

Yes, that sounds very interesting and likely to work, I think.