RSS 2.0 Feed

» Welcome Guest Log In :: Register

Pages: (501) < [1] 2 3 4 5 6 ... >   
  Topic: Uncommonly Dense Thread 3, The Beast Marches On...< Next Oldest | Next Newest >  
midwifetoad



Posts: 4003
Joined: Mar. 2008

(Permalink) Posted: Sep. 19 2009,14:33   

Here's my BASIC interpretation:
Quote

Sub Weasel()
   Dim AlphabetText As String
   Dim Target As String, Parent As String, BestChild As String, Child As String
   Dim I As Integer, Best As Integer, Generation As Integer, Copies As Integer
   
   AlphabetText = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "
   Target = "METHINKS IT IS LIKE A WEASEL"
   Copies = 100
   
   Parent = ""
   Best = 0
   For I = 1 To Len(Target)
       Parent = Parent + RandChar(AlphabetText)
   Next
   Debug.Print Parent
   Generation = 1
   While Best < Len(Target)
       For I = 1 To Copies
           Child = Parent
           Mid(Child, RandNum(Len(Child)), 1) = RandChar(AlphabetText)
           If SameLetters(Child, Target) > Best Then
               BestChild = Child
               Best = SameLetters(Child, Target)
           End If
       Next
       Parent = BestChild
       If Generation Mod 10 = 0 Then Debug.Print CStr(Generation) + ":" + Parent
       Generation = Generation + 1
   Wend
   Debug.Print CStr(Generation) + ":" + Parent
End Sub

Function RandChar(AlphabetText As String) As String
   Dim c As Integer
   Randomize
   c = Int((27 * Rnd) + 1)
   RandChar = Mid(AlphabetText, c, 1)
End Function

Function RandNum(I As Integer) As Integer
   Randomize
   RandNum = Int((I * Rnd) + 1)
End Function

Function SameLetters(Child As String, Target As String) As Integer
   Dim L As Integer, I As Integer
   L = 0
   For I = 1 To Len(Child)
       If Mid(Child, I, 1) = Mid(Target, I, 1) Then
           L = L + 1
       End If
   Next
   SameLetters = L
End Function


It works, but it can't be Dawkins' code, because only one character per child can mutate. The effective mutation rate is approximately 4 percent, which gives decent results, but conceptually it isn't Dawkins.

--------------
Any version of ID consistent with all the evidence is indistinguishable from evolution.

  
  15001 replies since Sep. 04 2009,16:20 < Next Oldest | Next Newest >  

Pages: (501) < [1] 2 3 4 5 6 ... >   


Track this topic Email this topic Print this topic

[ Read the Board Rules ] | [Useful Links] | [Evolving Designs]