Exemplo n.º 1
0
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    move to align on it. If we don't find it, we spin to keep looking
    """
    if player.firstFrame():
        player.stopWalking()
        player.brain.tracker.trackBall()

    if transitions.shouldApproachBall(player):
        return player.goNow('approachBall')

    # a time based check. may be a problem for goalie. if it's not good for him to
    # spin, he should prbly not be chaser anymore, so this wouldn't get reached
    if transitions.shouldSpinFindBall(player):
        return player.goNow('spinFindBall')

    ball = player.brain.ball
    if fabs(ball.bearing) < constants.SCAN_FIND_BEARING_THRESH:
        return player.stay()

    else:
        return player.goLater('spinFindBall')

    return player.stay()
Exemplo n.º 2
0
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    move to align on it. If we don't find it, we spin to keep looking
    """
    if player.firstFrame():
        player.stopWalking()
        player.brain.tracker.trackBall()

    if player.brain.play.isRole(GOALIE):
        if transitions.shouldTurnToBall_FoundBall(player):
            return player.goLater("turnToBall")
        elif transitions.shouldSpinFindBall(player):
            return player.goLater("spinFindBall")
    else:
        if transitions.shouldApproachBallWithLoc(player):
            player.brain.tracker.trackBall()
            return player.goLater("approachBallWithLoc")
        elif transitions.shouldSpinFindBall(player):
            return player.goLater("spinFindBall")
        elif transitions.shouldTurnToBall_FoundBall(player):
            return player.goLater("turnToBall")
        elif transitions.shouldSpinFindBall(player):
            return player.goLater("spinFindBall")

    if (
        abs(player.brain.ball.locBearing) < constants.SCAN_FIND_BEARING_THRESH
        or player.brain.ball.locDist < constants.SCAN_FIND_DIST_THRESH
        and not player.brain.play.isRole(GOALIE)
    ):
        return player.stay()
    elif player.brain.play.isRole(GOALIE) and abs(player.brain.ball.locBearing) < constants.SCAN_FIND_BEARING_THRESH:
        return player.stay()
    elif player.firstFrame():
        return player.goLater("spinFindBall")
    return player.stay()
Exemplo n.º 3
0
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    move to align on it. If we don't find it, we spin to keep looking
    """
    if player.firstFrame():
        player.stopWalking()
        player.brain.tracker.trackBall()

    if player.brain.playbook.role == pbc.GOALIE:
        if transitions.shouldTurnToBall_FoundBall(player):
            return player.goLater('turnToBall')
        elif transitions.shouldSpinFindBall(player):
            return player.goLater('spinFindBall')
    else:
        if transitions.shouldApproachBallWithLoc(player):
            player.brain.tracker.trackBall()
            return player.goLater('approachBallWithLoc')
        elif transitions.shouldSpinFindBall(player):
            return player.goLater('spinFindBall')
        elif transitions.shouldTurnToBall_FoundBall(player):
            return player.goLater('turnToBall')
        elif transitions.shouldSpinFindBall(player):
            return player.goLater('spinFindBall')

    if abs(player.brain.ball.locBearing) < constants.SCAN_FIND_BEARING_THRESH \
            or player.brain.ball.locDist < constants.SCAN_FIND_DIST_THRESH \
            and not player.brain.playbook.role == pbc.GOALIE:
        return player.stay()
    elif player.brain.playbook.role == pbc.GOALIE and \
            abs(player.brain.ball.locBearing) <\
            constants.SCAN_FIND_BEARING_THRESH:
        return player.stay()
    elif player.firstFrame():
        return player.goLater('spinFindBall')
    return player.stay()
Exemplo n.º 4
0
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    move to align on it. If we don't find it, we spin to keep looking
    """
    if player.firstFrame():
        player.stopWalking()
        player.brain.tracker.trackBall()

    if player.brain.play.isRole(GOALIE):
        if transitions.shouldTurnToBall_FoundBall(player):
            return player.goLater('turnToBall')
        elif transitions.shouldSpinFindBall(player):
            return player.goLater('spinFindBall')
    else:
        if transitions.shouldApproachBallWithLoc(player):
            player.brain.tracker.trackBall()
            return player.goLater('approachBallWithLoc')
        elif transitions.shouldSpinFindBall(player):
            return player.goLater('spinFindBall')
        elif transitions.shouldTurnToBall_FoundBall(player):
            return player.goLater('turnToBall')
        elif transitions.shouldSpinFindBall(player):
            return player.goLater('spinFindBall')

    if abs(player.brain.ball.locBearing) < constants.SCAN_FIND_BEARING_THRESH \
            or player.brain.ball.locDist < constants.SCAN_FIND_DIST_THRESH \
            and not player.brain.play.isRole(GOALIE):
        return player.stay()
    elif player.brain.play.isRole(GOALIE) and \
            abs(player.brain.ball.locBearing) <\
            constants.SCAN_FIND_BEARING_THRESH:
        return player.stay()
    elif player.firstFrame():
        return player.goLater('spinFindBall')
    return player.stay()
Exemplo n.º 5
0
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    mppove to align on it. If we don't find it, we spin to keep looking
    """
    player.brain.tracker.trackBall()

    if transitions.shouldChaseBall(player):
        return player.goNow('findBall')

    # a time based check.
    if transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()
Exemplo n.º 6
0
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    mppove to align on it. If we don't find it, we spin to keep looking
    """
    player.brain.tracker.trackBall()

    if transitions.shouldChaseBall(player):
        return player.goNow('findBall')

    # a time based check.
    if transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()
Exemplo n.º 7
0
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    mppove to align on it. If we don't find it, we spin to keep looking
    """
    player.brain.tracker.trackBall()

    if transitions.shouldChaseBall(player):
        return player.goNow('findBall')

    # a time based check. may be a problem for goalie. if it's not
    # good for him to spin, he should prbly not be chaser anymore, so
    # this wouldn't get reached
    if transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()
Exemplo n.º 8
0
def approachDangerousBall(player):
    if player.firstFrame():
        player.stopWalking()
    #print "approach dangerous ball"
    #single steps towards ball and goal with spin
    player.setSteps(0, 0, 0, 0)

    if not goalTran.dangerousBall(player):
        return player.goLater('approachBall')
    if transitions.shouldScanFindBall(player):
        return player.goLater('scanFindBall')
    elif transitions.shouldTurnToBall_ApproachBall(player):
        return player.goLater('turnToBall')
    elif transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()
Exemplo n.º 9
0
def approachDangerousBall(player):
    if player.firstFrame():
        player.stopWalking()
    #print "approach dangerous ball"
    #single steps towards ball and goal with spin
    player.setSteps(0, 0, 0, 0)

    if not goalTran.dangerousBall(player):
        return player.goLater('approachBall')
    if transitions.shouldScanFindBall(player):
        return player.goLater('scanFindBall')
    elif transitions.shouldTurnToBall_ApproachBall(player):
        return player.goLater('turnToBall')
    elif transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()
Exemplo n.º 10
0
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    mppove to align on it. If we don't find it, we spin to keep looking
    """
    player.brain.tracker.trackBallFixedPitch()

    if transitions.shouldChaseBall(player):
        return player.goNow('findBall')

    # a time based check. may be a problem for goalie. if it's not
    # good for him to spin, he should prbly not be chaser anymore, so
    # this wouldn't get reached
    if transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()
Exemplo n.º 11
0
def approachDangerousBall(player):
    if player.firstFrame():
        player.stopWalking()
    #print "approach dangerous ball"
    #single steps towards ball and goal with spin
    #player.setSteps(0, 0, 0, 0)
    ball = player.brain.ball
    my = player.brain.my
    if player.brain.nav.isStopped():
        if ball.dist >= 10:
            if ball.y > my.y + 7:
                player.brain.nav.walk(0, 10, 0)
            elif ball.y < my.y - 7:
                player.brain.nav.walk(0, -10, 0)

    if not goalTran.dangerousBall(player):
        return player.goLater('approachBall')
    if transitions.shouldScanFindBall(player):
        return player.goLater('scanFindBall')
    elif transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()