public List <Gene <T> > GetElites(int elitismOverride = 0) { List <Gene <T> > elites = new List <Gene <T> >(); if (Genes.Count < 1) { return(elites); } if (elitismOverride != 0) { elites.Capacity = elitismOverride; } else { elites.Capacity = settings.elitism; } FitnessScaling <T> .ScaleFitness(Genes, settings.scalingType); Genes.Sort(); Elite = new Gene <T>(Genes[0]); for (int i = 0; i < elites.Capacity && i < Genes.Count; i++) { elites.Add(new Gene <T>(Genes[i])); } return(elites); }
/// <summary> /// Sorts the genes by their historical Id markings (innovation numbers in old NEAT). /// </summary> public void SortGenesByConnectionId() { Genes.Sort((a, b) => a.Id.CompareTo(b.Id)); }