public List <NeuralNetwork> DoGeneration(List <float> fitnesses, bool complexify) { ResetAndKill(); for (int i = 0; i < genomes.Count; i++) { genomes[i].SetFitness(fitnesses[i]); } SortAndRecord(); SpeciateAndCaluclateSpawnLevels(); newPopulation.Clear(); //newPopulation.Add(Genome.RecycledGenome(genomes[0])); Genome offSpring = null; float bestFitness = -10000; int bestSpeciesIndex = -1; int storeNumber = Mathf.FloorToInt(genomes.Count * GA_Parameters.savePercentage / 100); if (storeNumber == 0) { storeNumber = 1; } oldGenomes.Add(new List <Genome>()); for (int i = 0; i < storeNumber; i++) { oldGenomes[oldGenomes.Count - 1].Add(new Genome(genomes[i])); } if (complexify) { Complexify(bestSpeciesIndex); } else { Simplify(bestSpeciesIndex); } Genome.AddToRecycledGenomes(genomes); genomes = newPopulation; newNetworks.Clear(); for (int i = 0; i < genomes.Count; i++) { bool leader = false; bool bestOfAll = false; for (int j = 0; j < species.Count; j++) { if (i == 0) { bestOfAll = true; break; } else if (genomes[i].GetID() == species[j].leader.GetID()) { leader = true; break; } } NeuralNetwork network = genomes[i].CreateNetwork(bestOfAll, leader); newNetworks.Add(network); } currentGeneration++; return(newNetworks); }