def test_find_best_neighbor_food_metric_1(self): near_sighted_creature = Creature([0, 0], starting_hunger=1, eye_sight=2) test_world = World(6, 0) food_cell = ArableLandCell(test_world, [2, 0], 0) test_world.set_cell(2, 0, food_cell) food_cell.set_food_level(2) submited_output = near_sighted_creature.find_best_neighbor( test_world, METRIC_FOOD) expected_output = [1, 0] self.assertEqual(submited_output, expected_output)
def test_find_best_neighbor_elevation_metric_2(self): near_sighted_creature = Creature([0, 0], starting_hunger=1, eye_sight=1) test_world = World(6, 0) high_cell1 = LandCell(test_world, [0, 0], 2) test_world.set_cell(0, 0, high_cell1) high_cell2 = LandCell(test_world, [1, 0], 0) test_world.set_cell(1, 0, high_cell2) high_cell3 = LandCell(test_world, [0, 1], 1) test_world.set_cell(0, 1, high_cell3) high_cell4 = LandCell(test_world, [1, 1], 2) test_world.set_cell(1, 1, high_cell4) submited_output = near_sighted_creature.find_best_neighbor( test_world, METRIC_ELEVATION) expected_output = [1, 0] self.assertEqual(submited_output, expected_output)
def test_find_best_neighbor_combined_metric_food_beyond_eyesight(self): near_sighted_creature = Creature([0, 0], starting_hunger=1, eye_sight=2) test_world = World(6, 0) high_cell1 = LandCell(test_world, [0, 0], 2) test_world.set_cell(0, 0, high_cell1) high_cell2 = LandCell(test_world, [1, 0], 3) test_world.set_cell(1, 0, high_cell2) high_cell3 = LandCell(test_world, [0, 1], 0) test_world.set_cell(0, 1, high_cell3) high_cell4 = LandCell(test_world, [1, 1], 2) test_world.set_cell(1, 1, high_cell4) food_cell = ArableLandCell(test_world, [3, 0], 0) test_world.set_cell(3, 0, food_cell) food_cell.set_food_level(2) submited_output = near_sighted_creature.find_best_neighbor( test_world, METRIC_COMBINED) expected_output = [0, 1] self.assertEqual(submited_output, expected_output)
def test_find_best_neighbor_does_not_crash(self): near_sighted_creature = Creature([0, 0], INIT_HUNGER, 2) test_world = World(6, 0) near_sighted_creature.find_best_neighbor(test_world, METRIC_COMBINED)