Beispiel #1
0
 /// <summary>
 /// Create next generation
 /// </summary>
 public void generate()
 {
     //Just overwrite current pop because we have the mating pool
     for (int i = 0; i < pop.Length; i++)
     {
         if (i < genome.clonesToKeep)
         {
             pop[i] = top[i].clone;
         }
         else
         {
             DNA.DNA <T> a     = matingPool[rand.Next(0, matingPool.Count)];
             DNA.DNA <T> b     = matingPool[rand.Next(0, matingPool.Count)];
             DNA.DNA <T> child = a.crossover(b);
             child.mutate(genome.mutationRate);
             pop[i] = child;
         }
     }
     calcFitness();
 }