private void CreateNewGeneration() { var myList = population.ToList(); myList.Sort((pair1, pair2) => - fitnesses[pair1].average.CompareTo(fitnesses[pair2].average)); Parameters[] nextGeneration = new Parameters[population_size]; nextGeneration[0] = myList[0]; int pos = 1; while (pos < population_size) { Parameters p1 = SelectCandidateByRank(myList); Parameters p2 = SelectCandidateByRank(myList); nextGeneration[pos] = MutationManager.Mutate(MutationManager.Crossover(p1, p2)); pos++; } population = nextGeneration; }