Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,13 +1,13 @@
|
|||
constant target = "METHINKS IT IS LIKE A WEASEL";
|
||||
constant mutate_chance = .08;
|
||||
constant alphabet = 'A'..'Z',' ';
|
||||
constant @alphabet = flat 'A'..'Z',' ';
|
||||
constant C = 100;
|
||||
|
||||
sub mutate { $^string.comb.map({ rand < mutate_chance ?? alphabet.pick !! $_ }).join }
|
||||
sub mutate { $^string.subst(/./, { rand < mutate_chance ?? @alphabet.pick !! $/ }, :g) }
|
||||
sub fitness { [+] $^string.comb Zeq state @ = target.comb }
|
||||
|
||||
loop (
|
||||
my $parent = alphabet.roll(target.chars).join;
|
||||
my $parent = @alphabet.roll(target.chars).join;
|
||||
$parent ne target;
|
||||
$parent = max :by(&fitness), mutate($parent) xx C
|
||||
) { printf "%6d: '%s'\n", $++, $parent }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue