public void CarnivoreFeedingCycle() { Carnivores = Carnivores.OrderBy(i => i.Fitness).ToList(); var kills = 0; foreach (var carn in Carnivores) { kills += carn.Feed(Herbivores); } KilledByCarnivores = kills; RemoveDeadIndividuals(); }
public void BirthCycle() { List <Herbivore> newbornHerbivores = new List <Herbivore>(); List <Carnivore> newbornCarnivores = new List <Carnivore>(); Herbivores = Herbivores.OrderBy(i => i.Fitness).ToList(); var numHerb = Herbivores.Count(); foreach (var herb in Herbivores) { var result = herb.Birth(numHerb); if (!(result is null)) { newbornHerbivores.Add((Herbivore)result); } } foreach (var child in newbornHerbivores) { Herbivores.Add(child); } NewHerbivores = newbornHerbivores.Count(); TotalHerbivoreLives += newbornHerbivores.Count(); Carnivores = Carnivores.OrderBy(i => i.Fitness).ToList(); var numCarn = Carnivores.Count(); foreach (var carn in Carnivores) { var result = carn.Birth(numCarn); if (!(result is null)) { newbornCarnivores.Add((Carnivore)result); } } foreach (var child in newbornCarnivores) { Carnivores.Add(child); } NewCarnivores = newbornCarnivores.Count(); TotalCarnivoreLives += newbornCarnivores.Count(); }