def test_update_visio_range_when_number_neighbors_is_greater_than_maximum_neighbors( self): glowworm1 = Glowworm(self.landscape_position1, self.gso_parameters) glowworm2 = Glowworm(self.landscape_position7, self.gso_parameters) glowworm1.luciferin = 5.0 glowworm1.vision_range = 3.0 glowworm1.max_vision_range = 3.0 glowworm2.luciferin = 5.0 glowworm2.vision_range = 3.0 glowworm2.max_vision_range = 3.0 for _ in range(23): glowworm1.neighbors.append(glowworm2) assert 23 == len(glowworm1.neighbors) glowworm1.update_vision_range() assert_almost_equals(1.5600000000000001, glowworm1.vision_range)
def test_update_visio_range_when_number_neighbors_is_less_than_maximum_neighbors( self): glowworm1 = Glowworm(self.landscape_position1, self.gso_parameters) glowworm2 = Glowworm(self.landscape_position7, self.gso_parameters) glowworm3 = Glowworm(self.landscape_position8, self.gso_parameters) glowworm1.luciferin = 3.0 glowworm1.vision_range = 2.0 glowworm1.max_vision_range = 1.0 glowworm2.luciferin = 4.0 glowworm2.vision_range = 2.0 glowworm2.max_vision_range = 1.0 glowworm3.luciferin = 5.0 glowworm3.vision_range = 2.0 glowworm3.max_vision_range = 1.0 glowworm1.neighbors = [glowworm2, glowworm3] glowworm1.update_vision_range() assert_almost_equals(1.0, glowworm1.vision_range)