Exemplo n.º 1
0
def approachBall(player):
    if player.firstFrame():
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            player.brain.nav.chaseBall(Navigator.QUICK_SPEED)
        else:
            player.brain.nav.chaseBall()

    if (transitions.shouldFindBall(player) or
        transitions.shouldSpinToBall(player)):
        return player.goLater('chase')

    if (transitions.shouldPrepareForKick(player) or
        player.brain.nav.isAtPosition()):
        player.inKickingState = True
        if player.shouldKickOff:
            if player.brain.ball.rel_y > 0:
                player.kick = kicks.LEFT_SHORT_STRAIGHT_KICK
            else:
                player.kick = kicks.RIGHT_SHORT_STRAIGHT_KICK
            player.shouldKickOff = False
            return player.goNow('positionForKick')
        else:
            return player.goNow('prepareForKick')
    else:
        return player.stay()
Exemplo n.º 2
0
def approachBall(player):
    if player.firstFrame():
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            player.brain.nav.chaseBall(Navigator.QUICK_SPEED)
        else:
            player.brain.nav.chaseBall()

    if (transitions.shouldFindBall(player)
            or transitions.shouldSpinToBall(player)):
        return player.goLater('chase')

    if (transitions.shouldPrepareForKick(player)
            or player.brain.nav.isAtPosition()):
        player.inKickingState = True
        if player.shouldKickOff:
            if player.brain.ball.rel_y > 0:
                player.kick = kicks.LEFT_SHORT_STRAIGHT_KICK
            else:
                player.kick = kicks.RIGHT_SHORT_STRAIGHT_KICK
            player.shouldKickOff = False
            return player.goNow('positionForKick')
        else:
            return player.goNow('prepareForKick')
    else:
        return player.stay()
Exemplo n.º 3
0
def approachBall(player):
    if player.brain.nav.dodging:
        return player.stay()

    if player.firstFrame():
        player.buffBoxFiltered = CountTransition(
            playOffTransitions.ballNotInBufferedBox, 0.8, 10)
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            if player.inKickOffPlay:
                return player.goNow('giveAndGo')
            else:
                return player.goNow('positionAndKickBall')

        elif player.penaltyKicking:
            return player.goNow('prepareForPenaltyKick')
        else:
            player.brain.nav.chaseBall(MAX_SPEED, fast=True)

    if (transitions.shouldPrepareForKick(player)
            or player.brain.nav.isAtPosition()):
        return player.goNow('positionAndKickBall')

    elif transitions.shouldDecelerate(player):
        player.brain.nav.chaseBall(MIN_SPEED, fast=True)
    else:
        player.brain.nav.chaseBall(MAX_SPEED, fast=True)
Exemplo n.º 4
0
def approachBall(player):
    if player.firstFrame():
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            player.brain.nav.chaseBall(Navigator.QUICK_SPEED, fast=True)
        elif player.penaltyKicking:
            return player.goNow("prepareForPenaltyKick")
        else:
            player.brain.nav.chaseBall(fast=True)

    # if (transitions.shouldFindBall(player)):
    #     return player.goLater('chase')

    # goalCenter = Location(nogginConstants.FIELD_WHITE_RIGHT_SIDELINE_X,
    #                               nogginConstants.CENTER_FIELD_Y)
    # ballLocation = Location(player.brain.ball.x, player.brain.ball.y)
    # headingBallToGoalCenter = ballLocation.headingTo(goalCenter)
    # print "headingBallToGoalCenter: ", headingBallToGoalCenter
    # return player.stay()

    if transitions.shouldPrepareForKick(player) or player.brain.nav.isAtPosition():
        player.inKickingState = True
        if player.shouldKickOff:
            if player.brain.ball.rel_y > 0:
                player.kick = kicks.LEFT_STRAIGHT_KICK
            else:
                player.kick = kicks.RIGHT_STRAIGHT_KICK
            return player.goNow("positionForKick")
        else:
            return player.goNow("prepareForKick")

    else:
        return player.stay()
Exemplo n.º 5
0
def approachBall(player):
    if player.brain.nav.dodging:
        return player.stay()

    if player.firstFrame():
        player.buffBoxFiltered = CountTransition(playOffTransitions.ballNotInBufferedBox,
                                                 0.8, 10)
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            if player.inKickOffPlay:
                return player.goNow('giveAndGo')
            else:
                return player.goNow('positionAndKickBall')

        elif player.penaltyKicking:
            return player.goNow('prepareForPenaltyKick')
        else:
            player.brain.nav.chaseBall(MAX_SPEED, fast = True)

    if (transitions.shouldPrepareForKick(player) or
        player.brain.nav.isAtPosition()):
        return player.goNow('positionAndKickBall')
    
    elif transitions.shouldDecelerate(player):
        player.brain.nav.chaseBall(MIN_SPEED, fast = True)
    else:
        player.brain.nav.chaseBall(MAX_SPEED, fast = True)
Exemplo n.º 6
0
def walkToWayPoint(player):
    if player.brain.nav.dodging:
        return player.stay()    

    if player.firstFrame():
        player.decider = KickDecider.KickDecider(player.brain)
        player.brain.tracker.trackBall()
    
    player.kick = player.decider.decidingStrategy()
    relH = player.decider.normalizeAngle(player.kick.setupH - player.brain.loc.h)

    ball = player.brain.ball

    if transitions.shouldDecelerate(player):
        speed = MIN_SPEED
    else:
        speed = MAX_SPEED

    if fabs(relH) <= constants.MAX_BEARING_DIFF:
        wayPoint = RobotLocation(ball.x - constants.WAYPOINT_DIST*cos(radians(player.kick.setupH)),
                                ball.y - constants.WAYPOINT_DIST*sin(radians(player.kick.setupH)),
                                player.brain.loc.h)

        player.brain.nav.goTo(wayPoint, Navigator.CLOSE_ENOUGH, speed, True, fast = True)

        if transitions.shouldSpinToKickHeading(player):
            return player.goNow('spinToKickHeading')

    else:
        player.brain.nav.chaseBall(speed, fast = True)

        if transitions.shouldPrepareForKick(player):
            return player.goLater('positionAndKickBall')

    return player.stay()
Exemplo n.º 7
0
def approachBall(player):
    if player.firstFrame():
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            player.brain.nav.chaseBall(Navigator.QUICK_SPEED, fast = True)
        else:
            player.brain.nav.chaseBall(fast = True)

    if (transitions.shouldFindBall(player)):
        print "DEBUG_SUIT: In 'approachBall', shouldFindBall is True. Switching to 'chase'."
        return player.goLater('chase')

    if (transitions.shouldPrepareForKick(player) or
        player.brain.nav.isAtPosition()):
        player.inKickingState = True

        if player.shouldKickOff:
            if player.brain.ball.rel_y > 0:
                player.kick = kicks.LEFT_STRAIGHT_KICK
            else:
                player.kick = kicks.RIGHT_STRAIGHT_KICK
            player.shouldKickOff = False
            return player.goNow('positionForKick')
        else:
            print "DEBUG_SUITE: In 'approachBall', either shouldPrepareForKick or nav.isAtPosition is True. Not a kickoff: switching to 'prepareForKick'."
            return player.goNow('prepareForKick')

    else:
        return player.stay()
Exemplo n.º 8
0
def approachBall(player):
    if player.firstFrame():
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            player.brain.nav.chaseBall(Navigator.QUICK_SPEED, fast = True)
        elif player.penaltyKicking:
            return player.goNow('prepareForPenaltyKick')
        else:
            player.brain.nav.chaseBall(fast = True)

    if transitions.shouldFindBall(player):
        return player.goLater('chase')

    if (transitions.shouldPrepareForKick(player) or
        player.brain.nav.isAtPosition()):

        if player.brain.nav.isAtPosition():
            print "isAtPosition() is causing the bug!"
        else:
            print "shouldPrepareForKick() is causing the bug!"
            print player.brain.ball.distance
            print player.brain.ball.vis.distance

        player.inKickingState = True
        if player.shouldKickOff:
            if player.brain.ball.rel_y > 0:
                player.kick = kicks.LEFT_STRAIGHT_KICK
            else:
                player.kick = kicks.RIGHT_STRAIGHT_KICK
            return player.goNow('positionForKick')
        else:
            return player.goNow('prepareForKick')
    else:
        return player.stay()
Exemplo n.º 9
0
def walkToWayPoint(player):
    if player.brain.nav.dodging:
        return player.stay()

    if player.firstFrame():
        player.decider = KickDecider.KickDecider(player.brain)
        player.brain.tracker.trackBall()

    player.kick = player.decider.new2016KickStrategy()
    relH = player.decider.normalizeAngle(player.kick.setupH -
                                         player.brain.loc.h)

    ball = player.brain.ball

    # print "In walkToWayPoint"

    if transitions.shouldDecelerate(player):
        # print "I should decelerate"
        speed = speeds.SPEED_SIX
    else:
        speed = speeds.SPEED_EIGHT

    if fabs(relH) <= 50:  #constants.MAX_BEARING_DIFF:
        wayPoint = RobotLocation(
            ball.x -
            constants.WAYPOINT_DIST * cos(radians(player.kick.setupH)),
            ball.y -
            constants.WAYPOINT_DIST * sin(radians(player.kick.setupH)),
            player.brain.loc.h)

        # print("Going to waypoint")
        player.brain.nav.goTo(wayPoint,
                              Navigator.GENERAL_AREA,
                              speed,
                              True,
                              fast=True)

        if transitions.shouldSpinToKickHeading(player):
            return player.goNow('spinToKickHeading')

    else:
        player.brain.nav.chaseBall(speed, fast=True)

        if transitions.shouldPrepareForKick(player):
            return player.goLater('dribble')

    return player.stay()
Exemplo n.º 10
0
def approachBall(player):
    if player.firstFrame():
        player.buffBoxFiltered = CountTransition(playOffTransitions.ballNotInBufferedBox, 0.8, 10)
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            if player.inKickOffPlay:
                return player.goNow("giveAndGo")
            else:
                return player.goNow("positionAndKickBall")

        elif player.penaltyKicking:
            return player.goNow("prepareForPenaltyKick")
        else:
            player.brain.nav.chaseBall(Navigator.QUICK_SPEED, fast=True)

    if transitions.shouldPrepareForKick(player) or player.brain.nav.isAtPosition():
        return player.goNow("positionAndKickBall")
Exemplo n.º 11
0
def prepareForPenaltyKick(player):
    """
    We're waiting here for a short time to psych out the opposing goalie,
    then turn very slightly if the flag is set.
    """
    if player.firstFrame():
        prepareForPenaltyKick.chase = False
        ball = player.brain.ball
        print "player.stateTime: ", player.stateTime
        #pseudo-random spin decision on which direction to kick
        now = time.time()
        if (int(now) % 2) == 0:
            player.penaltyKickRight = True
        else:
            player.penaltyKickRight = False

        print now
        print "Kicking Right? ", player.penaltyKickRight
        ball = player.brain.ball
        if player.penaltyKickRight:
            location = RelRobotLocation(ball.rel_x - 10, ball.rel_y + 5, 0)
        else:
            location = RelRobotLocation(ball.rel_x - 10, ball.rel_y - 5, 0)
        player.brain.nav.goTo(location, Navigator.PRECISELY,
                              Navigator.MEDIUM_SPEED, False, True, False,
                              False)
    else:
        ball = player.brain.ball
        if player.penaltyKickRight:
            location = RelRobotLocation(ball.rel_x - 10, ball.rel_y + 5, 0)
        else:
            location = RelRobotLocation(ball.rel_x - 10, ball.rel_y - 5, 0)
        player.brain.nav.updateDest(location)

    if prepareForPenaltyKick.chase:
        return player.stay()

    if (transitions.shouldPrepareForKick(player)
            or player.brain.nav.isAtPosition()):
        print "X: ", player.brain.ball.rel_x
        print "Y: ", player.brain.ball.rel_y
        player.brain.nav.stand()
        # prepareForPenaltyKick.chase = True
        return player.goNow('penaltyKickSpin')
    return player.stay()
Exemplo n.º 12
0
def approachBall(player):
    if player.firstFrame():
        player.brain.tracker.trackBall()
        player.brain.nav.chaseBall()
        
    # most of the time going to chase will kick back to here, lets us reset
    if transitions.shouldFindBall(player):
        return player.goLater('chase')
        
    if transitions.shouldPrepareForKick(player) or player.brain.nav.isAtPosition():
        if player.shouldKickOff:
            player.kick = kicks.LEFT_SHORT_STRAIGHT_KICK
            player.shouldKickOff = False
            return player.goNow('positionForKick')
        else:
            return player.goNow('prepareForKick')
    else:
        return player.stay()
Exemplo n.º 13
0
def prepareForPenaltyKick(player):
    """
    We're waiting here for a short time to psych out the opposing goalie,
    then turn very slightly if the flag is set.
    """
    if player.firstFrame():
        prepareForPenaltyKick.chase = False
        ball = player.brain.ball
        print "player.stateTime: ", player.stateTime
        #pseudo-random spin decision on which direction to kick
        now = time.time()
        if (int(now) % 2) == 0:
            player.penaltyKickRight = True
        else:
            player.penaltyKickRight = False

        print now
        print "Kicking Right? ", player.penaltyKickRight
        ball = player.brain.ball
        if player.penaltyKickRight:
            location = RelRobotLocation(ball.rel_x - 10, ball.rel_y + 5, 0)
        else:
            location = RelRobotLocation(ball.rel_x - 10, ball.rel_y - 5, 0)
        player.brain.nav.goTo(location, Navigator.PRECISELY, Navigator.MEDIUM_SPEED,
                              False, True, False, False)
    else:
        ball = player.brain.ball
        if player.penaltyKickRight:
            location = RelRobotLocation(ball.rel_x - 10, ball.rel_y + 5, 0)
        else:
            location = RelRobotLocation(ball.rel_x - 10, ball.rel_y - 5, 0)
        player.brain.nav.updateDest(location)

    if prepareForPenaltyKick.chase:
        return player.stay()

    if (transitions.shouldPrepareForKick(player) or
        player.brain.nav.isAtPosition()):
        print "X: ", player.brain.ball.rel_x
        print "Y: ", player.brain.ball.rel_y
        player.brain.nav.stand()
        # prepareForPenaltyKick.chase = True
        return player.goNow('penaltyKickSpin')
    return player.stay()
Exemplo n.º 14
0
def walkToWayPoint(player):
    if player.brain.nav.dodging:
        return player.stay()

    if player.firstFrame():
        player.decider = KickDecider.KickDecider(player.brain)
        player.brain.tracker.trackBall()

    player.kick = player.decider.decidingStrategy()
    relH = player.decider.normalizeAngle(player.kick.setupH -
                                         player.brain.loc.h)

    ball = player.brain.ball

    if transitions.shouldDecelerate(player):
        speed = MIN_SPEED
    else:
        speed = MAX_SPEED

    if fabs(relH) <= constants.MAX_BEARING_DIFF:
        wayPoint = RobotLocation(
            ball.x -
            constants.WAYPOINT_DIST * cos(radians(player.kick.setupH)),
            ball.y -
            constants.WAYPOINT_DIST * sin(radians(player.kick.setupH)),
            player.brain.loc.h)

        player.brain.nav.goTo(wayPoint,
                              Navigator.CLOSE_ENOUGH,
                              speed,
                              True,
                              fast=True)

        if transitions.shouldSpinToKickHeading(player):
            return player.goNow('spinToKickHeading')

    else:
        player.brain.nav.chaseBall(speed, fast=True)

        if transitions.shouldPrepareForKick(player):
            return player.goLater('positionAndKickBall')

    return player.stay()
Exemplo n.º 15
0
def walkToWayPoint(player):
    if player.brain.nav.dodging:
        return player.stay()

    if player.firstFrame():
        player.decider = KickDecider.KickDecider(player.brain)
        player.brain.tracker.trackBall()
    
    player.kick = player.decider.new2016KickStrategy()
    relH = player.decider.normalizeAngle(player.kick.setupH - player.brain.loc.h)

    ball = player.brain.ball

    # print "In walkToWayPoint"

    if transitions.shouldDecelerate(player):
        # print "I should decelerate"
        speed = speeds.SPEED_SIX
    else:
        speed = speeds.SPEED_EIGHT

    if fabs(relH) <= 50: #constants.MAX_BEARING_DIFF:
        wayPoint = RobotLocation(ball.x - constants.WAYPOINT_DIST*cos(radians(player.kick.setupH)),
                                 ball.y - constants.WAYPOINT_DIST*sin(radians(player.kick.setupH)),
                                 player.brain.loc.h)

        # print("Going to waypoint")
        player.brain.nav.goTo(wayPoint, Navigator.GENERAL_AREA, speed, True, fast = True)

        if transitions.shouldSpinToKickHeading(player):
            return player.goNow('spinToKickHeading')

    else:
        player.brain.nav.chaseBall(speed, fast = True)

        if transitions.shouldPrepareForKick(player):
            return player.goLater('dribble')

    return player.stay()
Exemplo n.º 16
0
def approachBall(player):
    if BoxTransitions.ballNotInBox(player):
        return player.goLater('positionAtHome')

    if player.firstFrame():
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            player.brain.nav.chaseBall(Navigator.QUICK_SPEED, fast=True)
        elif player.penaltyKicking:
            return player.goNow('prepareForPenaltyKick')
        else:
            player.brain.nav.chaseBall(fast=True)

    if transitions.shouldFindBall(player):
        return player.goLater('chase')

    if (transitions.shouldPrepareForKick(player)
            or player.brain.nav.isAtPosition()):

        if player.brain.nav.isAtPosition():
            print "isAtPosition() is causing the bug!"
        else:
            print "shouldPrepareForKick() is causing the bug!"
            print player.brain.ball.distance
            print player.brain.ball.vis.distance

        player.inKickingState = True
        if player.shouldKickOff:
            if player.brain.ball.rel_y > 0:
                player.kick = kicks.LEFT_SHORT_STRAIGHT_KICK
            else:
                player.kick = kicks.RIGHT_SHORT_STRAIGHT_KICK
            return player.goNow('positionForKick')
        else:
            return player.goNow('prepareForKick')
    else:
        return player.stay()