Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 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