コード例 #1
0
def isTrajHasAvoidPoints(trajectory, aimAction, initPlayerGrid, target1, target2, decisionSteps, conditionName):
    trajectory = list(map(tuple, trajectory))
    if conditionName == 'expCondition':
        avoidPoint = calAvoidPoints(initPlayerGrid, decisionSteps)
        hasMidPoint = 1 if avoidPoint in trajectory else 0
    if conditionName == 'lineCondition':
        avoidPoint = calMidPoints(initPlayerGrid, target1, target2)
        hasMidPoint = 1 if avoidPoint in trajectory else 0
        # hasMidPoint = 1 if aimAction[decisionSteps] == aimAction[decisionSteps - 1] else 0
    return hasMidPoint
コード例 #2
0
def calDisToMidPointTrajLen(trajectory, target1, target2):
    trajectory = list(map(tuple, trajectory))
    playerGrid = trajectory[0]
    midPoint = calMidPoints(playerGrid, target1, target2)
    disToMidPointTraj = [
        calculateGridDis(grid, midPoint) for grid in trajectory
    ]

    meanDis = np.mean(disToMidPointTraj)
    return meanDis
コード例 #3
0
def calDisToMidPointTraj(trajectory, target1, target2):
    trajectory = list(map(tuple, trajectory))
    playerGrid = trajectory[0]
    midPoint = calMidPoints(playerGrid, target1, target2)
    disToMidPointTraj = [
        calculateGridDis(grid, midPoint) for grid in trajectory
    ]

    x = np.divide(np.arange(len(disToMidPointTraj)),
                  len(disToMidPointTraj) - 1)
    y = np.array(disToMidPointTraj)

    f = interp1d(x, y, kind='nearest')
    xnew = np.linspace(0., 1., 30)
    posterior = f(xnew)
    return posterior
    def __call__(self, selfGrid, target1, target2, trajectory):
        initGrid = trajectory[0]
        goal = trajectory[-1]
        midpoint = calMidPoints(selfGrid, target1, target2)
        zone = calculateAvoidCommitmnetZoneAll(initGrid, target1, target2)
        if midpoint:
            disToMidPoint = calculateGridDis(selfGrid, midpoint)
            disToTargets = [calculateGridDis(selfGrid, target) for target in[target1, target2]]
            isInDeliberationArea = 1 if disToMidPoint < min(disToTargets) else 0

            if isInDeliberationArea:
                actionDis = self.goalPolicy(selfGrid, midpoint)
            else:
                actionDis = self.goalPolicy(selfGrid, goal)
        else:
            actionDis = self.goalPolicy(selfGrid, goal)
        return actionDis
コード例 #5
0
def isTrajHasAvoidPoints(trajectory, aimAction, initPlayerGrid, target1, target2, decisionSteps, conditionName, obstacles):
    trajectory = list(map(tuple, trajectory))
    if conditionName == 'expCondition':
        avoidPoint = calAvoidPoints(initPlayerGrid, decisionSteps)
        hasMidPoint = 1 if avoidPoint in trajectory else 0
        if decisionSteps == 0:
            nextStep = trajectory[1]
            nextStepInLineWithObstacles = [isGridsALine(nextStep, targetGrid) for targetGrid in obstacles]
            hasMidPoint = 1 if sum(nextStepInLineWithObstacles) > 2 else 0
        if decisionSteps == 1:
            avoidPoint = calAvoidPoints(initPlayerGrid, decisionSteps - 1)
            hasMidPoint = 1 if avoidPoint in trajectory else 0

    if conditionName == 'lineCondition':
        avoidPoint = calMidPoints(initPlayerGrid, target1, target2)
        hasMidPoint = 1 if avoidPoint in trajectory else 0
        # hasMidPoint = 1 if aimAction[decisionSteps] == aimAction[decisionSteps - 1] else 0
    return hasMidPoint
コード例 #6
0
def isTrajHasMidPoints(trajectory, target1, target2):
    trajectory = list(map(tuple, trajectory))
    initPlayerGrid = trajectory[0]
    midPoint = calMidPoints(initPlayerGrid, target1, target2)
    hasMidPoint = 1 if midPoint in trajectory else 0
    return hasMidPoint