public Phenotype BreedWith(Organism other, InnovationCacher currentGeneration) { Organism dominantParent; if (CalculateFitness() == other.CalculateFitness()) { dominantParent = Utility.RandomBoolean() ? this : other; } else { dominantParent = CalculateFitness() > other.CalculateFitness() ? this : other; } var child = dominantParent.Chromosome; var sizeOfSmallerParent = System.Math.Min(Chromosome.GeneCount, other.Chromosome.GeneCount); for (var i = 0; i < sizeOfSmallerParent && child.GetGeneAt(i) == other.Chromosome.GetGeneAt(i); ++i) { if (Utility.RandomBoolean()) { child.GetGeneAt(i).Weight = other.Chromosome.GetGeneAt(i).Weight; } } return(new Phenotype(_neat, child, currentGeneration)); }