예제 #1
0
def orbitBeforeKick(player):
    """
    State for circling the ball when we're facing our goal.
    """
    brain = player.brain
    my = brain.my
    if player.firstFrame():
        player.orbitStartH = my.h
        brain.CoA.setRobotGait(brain.motion)
        brain.tracker.trackBall()

        shotPoint = KickingHelpers.getShotCloseAimPoint(player)
        bearingToGoal = MyMath.getRelativeBearing(my.x, my.y, my.h,
                                                  shotPoint[0],
                                                  shotPoint[1] )
        spinDir = -MyMath.sign(bearingToGoal)
        player.brain.nav.orbitAngle(spinDir * 90)
    if not player.brain.tracker.activeLocOn and \
            transitions.shouldScanFindBall(player):
        player.brain.CoA.setRobotGait(player.brain.motion)
        return player.goLater('scanFindBall')
    elif brain.ball.dist > constants.STOP_ORBIT_BALL_DIST:
        return player.goLater('chase')

    if player.brain.nav.isStopped() and not player.firstFrame():
        return player.goLater('positionForKick')
    return player.stay()
예제 #2
0
def orbitBeforeKick(player):
    """
    State for circling the ball when we're facing our goal.
    """
    brain = player.brain
    my = brain.my
    if player.firstFrame():
        player.orbitStartH = my.h
        brain.CoA.setRobotGait(brain.motion)
        brain.tracker.trackBall()

        shotPoint = KickingHelpers.getShotCloseAimPoint(player)
        bearingToGoal = my.getRelativeBearing(shotPoint)
        spinDir = -MyMath.sign(bearingToGoal)
        player.brain.nav.orbitAngle(spinDir * 90)
    if not player.brain.tracker.activeLocOn and \
            transitions.shouldScanFindBall(player):
        player.brain.CoA.setRobotGait(player.brain.motion)
        return player.goLater('scanFindBall')
    elif brain.ball.dist > constants.STOP_ORBIT_BALL_DIST:
        return player.goLater('chase')

    if player.brain.nav.isStopped() and not player.firstFrame():
        return player.goLater('positionForKick')
    return player.stay()
예제 #3
0
def shouldStopPenaltyKickDribbling(player):
    """
    While dribbling we should stop
    """
    my = player.brain.my
    dribbleAimPoint = helpers.getShotCloseAimPoint(player)
    goalBearing = my.getRelativeBearing(dribbleAimPoint)
    return (inPenaltyKickStrikezone(player) or
            player.brain.ball.relX > constants.STOP_DRIBBLE_X or
            fabs(player.brain.ball.relY) > constants.STOP_DRIBBLE_Y or
            fabs(goalBearing) > constants.STOP_DRIBBLE_BEARING or
            player.counter > constants.STOP_PENALTY_DRIBBLE_COUNT)
예제 #4
0
def shouldStopPenaltyKickDribbling(player):
    """
    While dribbling we should stop
    """
    my = player.brain.my
    dribbleAimPoint = helpers.getShotCloseAimPoint(player)
    goalBearing = my.getRelativeBearing(dribbleAimPoint)
    return (inPenaltyKickStrikezone(player)
            or player.brain.ball.relX > constants.STOP_DRIBBLE_X
            or abs(player.brain.ball.relY) > constants.STOP_DRIBBLE_Y
            or abs(goalBearing) > constants.STOP_DRIBBLE_BEARING
            or player.counter > constants.STOP_PENALTY_DRIBBLE_COUNT)
예제 #5
0
def shootBallClose(player):
    """
    Slam-dunk!
    """
    my = player.brain.my
    shotAimPoint = helpers.getShotCloseAimPoint(player)
    leftPostBearing = MyMath.getRelativeBearing(my.x, my.y, my.h,
                                                NogginConstants.
                                                LANDMARK_OPP_GOAL_LEFT_POST_X,
                                                NogginConstants.
                                                LANDMARK_OPP_GOAL_LEFT_POST_Y)
    rightPostBearing = MyMath.getRelativeBearing(my.x, my.y, my.h,
                                                 NogginConstants.
                                                 LANDMARK_OPP_GOAL_RIGHT_POST_X,
                                                 NogginConstants.
                                                 LANDMARK_OPP_GOAL_RIGHT_POST_Y)
    # Am I looking between the posts?
    if (rightPostBearing < -constants.KICK_STRAIGHT_POST_BEARING and
        leftPostBearing > constants.KICK_STRAIGHT_POST_BEARING):
        return player.goNow('kickBallStraight')

    leftShotPointBearing = MyMath.getRelativeBearing(my.x, my.y, my.h,
                                                     constants.
                                                     SHOOT_AT_LEFT_AIM_POINT[0],
                                                     constants.
                                                     SHOOT_AT_LEFT_AIM_POINT[1])

    rightShotPointBearing = MyMath.getRelativeBearing(my.x, my.y, my.h,
                                                      constants.
                                                      SHOOT_AT_RIGHT_AIM_POINT[0],
                                                      constants.
                                                      SHOOT_AT_RIGHT_AIM_POINT[1])

    # Turn to the closer shot point
    if fabs(rightShotPointBearing) < fabs(leftShotPointBearing):
        angleToAlign = rightShotPointBearing
    else :
        angleToAlign = leftShotPointBearing

    if constants.SHOOT_BALL_SIDE_KICK_ANGLE > abs(angleToAlign) > \
            constants.SHOOT_BALL_LOC_ALIGN_ANGLE and \
            not player.hasAlignedOnce:
        player.angleToAlign = angleToAlign
        player.bigKick = False
        return player.goNow('alignOnBallStraightKick')
    elif angleToAlign > constants.SHOOT_BALL_SIDE_KICK_ANGLE:
        return player.goNow('kickBallLeft')
    elif angleToAlign < -constants.SHOOT_BALL_SIDE_KICK_ANGLE:
        return player.goNow('kickBallRight')
    else :
        player.bigKick = False
        return player.goLater('kickBallStraight')
예제 #6
0
def shouldStopDribbling(player):
    """
    While dribbling we should stop
    """
    my = player.brain.my
    dribbleAimPoint = helpers.getShotCloseAimPoint(player)
    goalBearing = my.getRelativeBearing(dribbleAimPoint)
    return (player.penaltyKicking or inOppGoalbox(player)
            or player.brain.ball.relX > constants.STOP_DRIBBLE_X
            or abs(player.brain.ball.relY) > constants.STOP_DRIBBLE_Y
            or abs(goalBearing) > constants.STOP_DRIBBLE_BEARING
            or player.brain.my.x < (NogginConstants.FIELD_WHITE_WIDTH / 3.0 +
                                    NogginConstants.GREEN_PAD_X))
예제 #7
0
def shouldStopDribbling(player):
    """
    While dribbling we should stop
    """
    my = player.brain.my
    dribbleAimPoint = helpers.getShotCloseAimPoint(player)
    goalBearing = my.getRelativeBearing(dribbleAimPoint)
    return (player.penaltyKicking or
            player.brain.my.inOppGoalbox() or
            player.brain.ball.relX > constants.STOP_DRIBBLE_X or
            fabs(player.brain.ball.relY) > constants.STOP_DRIBBLE_Y or
            fabs(goalBearing) > constants.STOP_DRIBBLE_BEARING or
            player.brain.my.x < ( NogginConstants.FIELD_WHITE_WIDTH / 3.0 +
                                  NogginConstants.GREEN_PAD_X))
예제 #8
0
def shouldDribble(player):
    """
    Ball is in between us and the opp goal, let's dribble for a while
    """
    my = player.brain.my
    dribbleAimPoint = helpers.getShotCloseAimPoint(player)
    goalBearing = my.getRelativeBearing(dribbleAimPoint)
    return (constants.USE_DRIBBLE and not player.penaltyKicking
            and 0 < player.brain.ball.relX < constants.SHOULD_DRIBBLE_X
            and 0 < abs(player.brain.ball.relY) < constants.SHOULD_DRIBBLE_Y
            and abs(goalBearing) < constants.SHOULD_DRIBBLE_BEARING
            and not inOppGoalbox(player) and player.brain.my.x >
            (NogginConstants.FIELD_WHITE_WIDTH / 3.0 +
             NogginConstants.GREEN_PAD_X))
예제 #9
0
def shouldDribble(player):
    """
    Ball is in between us and the opp goal, let's dribble for a while
    """
    if constants.USE_DRIBBLE:
        my = player.brain.my
        dribbleAimPoint = helpers.getShotCloseAimPoint(player)
        goalBearing = my.getRelativeBearing(dribbleAimPoint)
        return  (not player.penaltyKicking and
                 0 < player.brain.ball.relX < constants.SHOULD_DRIBBLE_X and
                 0 < fabs(player.brain.ball.relY) < constants.SHOULD_DRIBBLE_Y and
                 fabs(goalBearing) < constants.SHOULD_DRIBBLE_BEARING and
                 not player.brain.my.inOppGoalbox() and
                 player.brain.my.x > (
                     NogginConstants.FIELD_WHITE_WIDTH / 3.0 +
                     NogginConstants.GREEN_PAD_X) )
예제 #10
0
def shootBallClose(player):
    """
    Slam-dunk!
    """
    my = player.brain.my
    shotAimPoint = helpers.getShotCloseAimPoint(player)
    leftPostBearing = my.getRelativeBearing(player.brain.oppGoalLeftPost)
    rightPostBearing = my.getRelativeBearing(player.brain.oppGoalRightPost)

    # Am I looking between the posts?
    if (rightPostBearing < -constants.KICK_STRAIGHT_POST_BEARING and
        leftPostBearing > constants.KICK_STRAIGHT_POST_BEARING):
        return player.goNow('kickBallStraight')

    leftShotPointBearing = my.getRelativeBearing(constants.SHOOT_AT_LEFT_AIM_POINT)

    rightShotPointBearing = my.getRelativeBearing(constants.SHOOT_AT_RIGHT_AIM_POINT)

    # Turn to the closer shot point
    if fabs(rightShotPointBearing) < fabs(leftShotPointBearing):
        angleToAlign = rightShotPointBearing
    else :
        angleToAlign = leftShotPointBearing

    if constants.SHOOT_BALL_SIDE_KICK_ANGLE > abs(angleToAlign) > \
            constants.SHOOT_BALL_LOC_ALIGN_ANGLE and \
            not player.hasAlignedOnce:
        player.angleToAlign = angleToAlign
        player.bigKick = False
        return player.goNow('alignOnBallStraightKick')
    elif angleToAlign > constants.SHOOT_BALL_SIDE_KICK_ANGLE:
        return player.goNow('kickBallLeft')
    elif angleToAlign < -constants.SHOOT_BALL_SIDE_KICK_ANGLE:
        return player.goNow('kickBallRight')
    else :
        player.bigKick = False
        return player.goLater('kickBallStraight')