示例#1
0
文件: main.py 项目: walterm/6.S078-A1
        sys.exit()

    drawPath(robot.plan, delta_x, delta_y)

    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