/// <summary> /// Create a child using crossover reproduction between the two parents. /// </summary> /// <param name="one"></param> /// <param name="two"></param> /// <returns></returns> private Individual GenerateChild(Individual one, Individual two) { //StringBuilder genome = new StringBuilder(one.Genome.Length); RGB[] genome = new RGB[one.Genome.Length]; int crossoverPoint = one.Genome.Length / 2; GetFirstParentGenome(one, genome, crossoverPoint); GetSecondParentGenome(two, genome, crossoverPoint); return new Individual(genome); }
/// <summary> /// Give the child the second parents genomes. /// </summary> /// <param name="parentTwo"></param> /// <param name="childCoins"></param> /// <param name="crossoverPoint"></param> private void GetSecondParentGenome(Individual two, RGB[] genome, int crossoverPoint) { for (int index = crossoverPoint; index < two.Genome.Length; index++) genome[index] = (two.Genome[index]); }
/// <summary> /// give the child the first parents genome. /// </summary> /// <param name="parentOne"></param> /// <param name="childCoins"></param> /// <param name="crossoverPoint"></param> private void GetFirstParentGenome(Individual one, RGB[] genome, int crossoverPoint) { for (int index = 0; index < crossoverPoint; index++) genome[index] = (one.Genome[index]); }
public Individual(RGB[] genome) { _genome = genome; }