def test_false_when_prob_of_killing_is_zero(self, example_properties): """ Asserts that kill method returns False when prob_kill is zero. """ herbivore = Herbivore(example_properties) carnivore = Carnivore(example_properties) herbivore.find_fitness() carnivore.fitness = 0.5 assert carnivore.kill(herbivore) is False
def test_feeding_carnivore_appetite(self): """ Test for a fit carnivore's feeding method, with low appetite. Returns ------- """ c1 = Carnivore(1, 20) c1.fitness = 1 c1.set_parameters({'DeltaPhiMax': 1.00001, 'F': 10.0}) j1 = Jungle() j1.add_herbivore(5,20) j1.herbivores[0].fitness = 0 boolean = c1.feeding(j1.herbivores) c1.set_parameters({'DeltaPhiMax': 10.0, 'F': 50.0}) # default-value assert c1.weight == 27.5 assert boolean == [False]
def test_feeding_carnivore_unfit(self): """ Test for carnivore feeding method, with unfit carnivore. Returns ------- """ c1 = Carnivore(1, 20) c1.fitness = 0.0001 c1.set_parameters({'DeltaPhiMax': 1.00001}) j1 = Jungle() j1.add_herbivore(5,10) j1.herbivores[0].fitness = 1 boolean = c1.feeding(j1.herbivores) c1.set_parameters({'DeltaPhiMax': 10.0}) # default-value assert c1.weight == 20 assert boolean == [True]