Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,39 @@
|
|||
'EVOLUTION
|
||||
|
||||
target="METHINKS IT IS LIKE A WEASEL"
|
||||
le=len target
|
||||
progeny=string le,"X"
|
||||
|
||||
quad seed
|
||||
declare QueryPerformanceCounter lib "kernel32.dll" (quad*q)
|
||||
QueryPerformanceCounter seed
|
||||
|
||||
Function Rand(sys max) as sys
|
||||
mov eax,max
|
||||
inc eax
|
||||
imul edx,seed,0x8088405
|
||||
inc edx
|
||||
mov seed,edx
|
||||
mul edx
|
||||
return edx
|
||||
End Function
|
||||
|
||||
sys ls=le-1,cp=0,ct=0,ch=0,fit=0,gens=0
|
||||
|
||||
do '1 mutation per generation
|
||||
i=1+rand ls 'mutation position
|
||||
ch=64+rand 26 'mutation ascii code
|
||||
if ch=64 then ch=32 'change '@' to ' '
|
||||
ct=asc target,i 'target ascii code
|
||||
cp=asc progeny,i 'parent ascii code
|
||||
'
|
||||
if ch=ct then
|
||||
if cp<>ct then
|
||||
mid progeny,i,chr ch 'carry improvement
|
||||
fit++ 'increment fitness
|
||||
end if
|
||||
end if
|
||||
gens++
|
||||
if fit=le then exit do 'matches target
|
||||
end do
|
||||
print progeny " " gens 'RESULT (range 1200-6000 generations)
|
||||
Loading…
Add table
Add a link
Reference in a new issue