Beispiel #1
0
 public void HerbivoreFeedingCycle()
 {
     Herbivores = Herbivores.OrderBy(i => i.Fitness).ToList();
     foreach (var herb in Herbivores)
     {
         Food = herb.Feed(Food);
     }
 }
Beispiel #2
0
        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();
        }