Beispiel #1
0
        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;
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public void reproduceHerbivore()
        {
            var toRepoduce = Herbivores.Where(h => h.HitPoints > 150 && h.Satiety > 150).ToList();

            foreach (var tr in toRepoduce)
            {
                Herbivores.Add(tr);
            }
        }
Beispiel #5
0
        public void deleteHerbivore()
        {
            var toDelete = Herbivores.Where(h => h.HitPoints <= 0).ToList();

            foreach (var td in toDelete)
            {
                Herbivores.Remove(td);
            }
        }