コード例 #1
0
ファイル: main.py プロジェクト: walterm/6.S078-A1
        # 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
        points = []
        for i in range(abs(targetx - currentx)):
            for j in range(abs(targety - currenty)):
                points += [robot.potentialPoints(dx * i, dy * j)]
        check = map(lambda s: testCollision(s, obstacles), points)

        if True in check:
            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

        # otherwise we're clear
        robot.translate(target[0], target[1])
        safe.append(target)

    print len(safe)