Beispiel #1
0
    def test_feeding_none(self):
        """
        Test for herbivore feeding method with no fodder.

        Returns
        -------

        """
        h1 = Herbivore(age=5, weight=20)
        j1 = Jungle()
        j1.fodder = 0
        h1.feeding(j1)
        assert h1.weight == 20
        assert j1.get_fodder() == 0
Beispiel #2
0
 def test_feed_herbivore(self, animal_list):
     test_jungle = Jungle()
     test_jungle.herbivores.append(Herbivore(5, 40))
     test_jungle.herbivores.append(Herbivore(50, 4))
     test_jungle.herbivores = (test_jungle.sort_by_fitness(
         test_jungle.herbivores))
     test_jungle.fodder = 15
     a_weight = test_jungle.herbivores[0].weight
     b_weight = test_jungle.herbivores[1].weight
     #  herbivore F is 10 and beta is 0.9
     #  b will eat 10 and gain 10*0.9 weight
     #  a will eat 5 and gain 5*0.9 weight
     a, b = test_jungle.herbivores
     test_jungle.feed_herbivores()
     assert test_jungle.fodder == 0
     #  b will be last because its fitness will be higher
     assert b.weight == b_weight + 10 * 0.9
     assert a.weight == a_weight + 5 * 0.9
Beispiel #3
0
 def test_grow(self):
     jungle = Jungle()
     jungle.fodder = 0
     jungle.grow()
     assert jungle.fodder == Jungle.f_max
Beispiel #4
0
 def test_feed_herbivores(self):
     jungle = Jungle()
     jungle.herbivores.append(Herbivore())
     jungle.fodder = 1
     jungle.feed_herbivores()
     assert jungle.fodder == 0