public void Speciate(IGenome genome) { bool newSpecies = true; // Remove from current species if (genome.SpeciesId.HasValue) { Species.First(s => s.Id == genome.SpeciesId).Genomes.Remove(genome); } foreach (ISpecies species in Species.Where(s => s.Genomes.Any())) { IGenome representative = species.Genomes.First(); if (genome.IsCompatible(representative)) { species.Genomes.Add(genome); genome.SpeciesId = species.Id; newSpecies = false; break; } } ; if (newSpecies) { ISpecies species = new Species(); species.Genomes.Add(genome); genome.SpeciesId = species.Id; Species.Add(species); } }