Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
|||
200 Constant new: C
|
||||
5 Constant new: RATE
|
||||
|
||||
: randChar // -- c
|
||||
27 rand dup 27 == ifTrue: [ drop ' ' ] else: [ 'A' + 1- ] ;
|
||||
|
||||
: fitness(a b -- n)
|
||||
a b zipWith(#==) sum ;
|
||||
|
||||
: mutate(s -- s')
|
||||
s map(#[ 100 rand RATE <= ifTrue: [ drop randChar ] ]) charsAsString ;
|
||||
|
||||
: evolve(target)
|
||||
| parent |
|
||||
ListBuffer init(target size, #randChar) charsAsString ->parent
|
||||
|
||||
1 while ( parent target <> ) [
|
||||
ListBuffer init(C, #[ parent mutate ]) dup add(parent)
|
||||
maxFor(#[ target fitness ]) dup ->parent . dup println 1+
|
||||
] drop ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue