예제 #1
0
 def test_get_dist(self):
     coord1 = Coord(1, 1)
     coord2 = Coord(2, 2)
     coord3 = Coord(10, 10)
     self.assertEqual(coord1.get_dist(coord2), 2)
     self.assertEqual(coord1.get_dist(coord3), 18)
     with self.assertRaises(NotImplementedError):
         coord3.get_dist(None)
예제 #2
0
 def get_neighbor_coords(self, coord: Coord):
     '''returns all non-diagonal adjacent nodes that do not contain predators. Used for BFS to find prey but avoid other predators'''
     return list(
         filter(
             lambda x: coord.get_dist(x) == 1,
             list(
                 filter(lambda x: not isinstance(x.get_value(), Predator),
                        self.coords))))
 def get_neighbor_coords(self, coord: Coord):
     '''returns all non-diagonal adjacent nodes'''
     return list(
         filter(lambda x: coord.get_dist(x) == 1,
                self.get_unoccupied_coords()))