Genome.crossover constructor
Implementation
factory Genome.crossover(Genome fittest, Genome weak) {
var child = Genome.clone(fittest);
for (var fitLink in child.connections) {
if (weak.connections.any((l) => l.identifier == fitLink.identifier)) {
var weakLink = weak.connections.singleWhere((l) => l.identifier == fitLink.identifier);
List<Connection> choices = [weakLink, fitLink];
choices.shuffle();
var choice = choices.first;
if (choice != fitLink) {
fitLink.weight = weakLink.weight;
fitLink.enabled = weakLink.enabled;
}
}
}
return child;
}