def __init__(self, dimension, start_coords, goal_coords): self.goal_coords = goal_coords self.goal_node = PathNode(goal_coords) self.start_node = PathNode(start_coords) self.astar = AStarAlgo(graph=GridSpace(dimension.grid), start_node=self.start_node, goal_node=self.goal_node, is_goal=self.is_goal, heuristics=self.heuristics) self.t_start = time.time() self.path = None
def _check_status(self, b_obj): gs = GridSpace(self.blackboard.grid) self.start_state = gs.get_state_coords(self.start_coords) self.target_state = gs.get_state_coords(self.target_coords) go = gs.can_go(self.start_state, self.target_state) if not go: log.msg('cannot go between %s %s' % (self.start_state, self.target_state)) return Status.failure if not self.was_at_target: self.was_at_target = self.target_state.vertical_center_in(b_obj.position) if self.target_state.base_in(b_obj.aabb) and self.target_state.touch_platform(b_obj.position): return Status.success return Status.running
def positions_to_dig(self, coords): gs = GridSpace(self.grid) return list(gs.positions_to_dig(coords))