public void RemoveDeadIndividuals() { DeadCarnivores += Carnivores.Where(i => !i.IsAlive).Count(); DeadHerbivores += Herbivores.Where(i => !i.IsAlive).Count(); List <Herbivore> survivingHerbivores = new List <Herbivore>(); foreach (var herb in Herbivores) { if (herb.IsAlive) { survivingHerbivores.Add(herb); } } List <Carnivore> survivingCarnivores = new List <Carnivore>(); foreach (var carn in Carnivores) { if (carn.IsAlive) { survivingCarnivores.Add(carn); } } Herbivores = survivingHerbivores; Carnivores = survivingCarnivores; }
public int ResetMigrationParameter() { var migrations = Carnivores.Where(i => i.Migrated).Count() + Herbivores.Where(i => i.Migrated).Count(); Carnivores.ForEach(i => i.Migrated = false); Herbivores.ForEach(i => i.Migrated = false); return(migrations); }
public int ResetGivenBirthParameter() { var births = Carnivores.Where(i => i.GivenBirth).Count() + Herbivores.Where(i => i.GivenBirth).Count(); Carnivores.ForEach(i => i.GivenBirth = false); Herbivores.ForEach(i => i.GivenBirth = false); return(births); }