obstacles = [o]#,o1] safe = [robot.loc] # while it's not at the goal state while goalTest(robot.loc, goal) == False: target = robot.plan.pop(0) targetx = target[0] * delta_x targety = target[1] * delta_y # make sure that point itself has space obsCheck = map(lambda o: o.containsPoint((targetx, targety)), obstacles) if True in obsCheck: x, y = safe.pop() robot.translate(x, y) robot.plan = node.search(robot.loc, goal) drawPath(robot.plan, delta_x, delta_y) node.BadLocations.addBadLoc(target) continue # make sure every place along that path is possible targetx = target[0] * delta_x targety = target[1] * delta_y currentx = robot.loc[0] * delta_x currenty = robot.loc[1] * delta_y # we're headed _dir = direction(robot.loc, target) dx, dy = _dir
def search(self, x): return node.search(self.root, x)