Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
|
|
@ -19,17 +19,17 @@ extension evoHelper
|
|||
= 0.repeatTill(self).selectBy::(x => randomChar).summarize(new StringWriter());
|
||||
|
||||
fitnessOf(s)
|
||||
= self.zipBy(s, (a,b => a==b ? 1 : 0)).summarize(new Integer()).toInt();
|
||||
= self.zipBy(s, (a,b => (a==b) ? 1 : 0)).summarize(new Integer()).toInt();
|
||||
|
||||
mutate(p)
|
||||
= self.selectBy::(ch => rnd.nextReal() <= p ? randomChar : ch).summarize(new StringWriter());
|
||||
= self.selectBy::(ch => (rnd.nextReal() <= p) ? randomChar : ch).summarize(new StringWriter());
|
||||
}
|
||||
|
||||
class EvoAlgorithm : Enumerator
|
||||
{
|
||||
object _target;
|
||||
object _current;
|
||||
object _variantCount;
|
||||
object _target;
|
||||
object? _current;
|
||||
object _variantCount;
|
||||
|
||||
constructor new(s,count)
|
||||
{
|
||||
|
|
@ -67,10 +67,10 @@ public program()
|
|||
var attempt := new Integer();
|
||||
EvoAlgorithm.new(Target,C).forEach::(current)
|
||||
{
|
||||
console
|
||||
Console
|
||||
.printPaddingLeft(10,"#",attempt.append(1))
|
||||
.printLine(" ",current," fitness: ",current.fitnessOf(Target))
|
||||
};
|
||||
|
||||
console.readChar()
|
||||
Console.readChar()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue