Esempio n. 1
0
def DecideNextAction():
    global lockMode

    Global.myRole = Constant.ATTACKER
    
    if GrabTurnKick.lockMode:
        GrabTurnKick.DecideNextAction()
        lockMode = True
        return

    lockMode = False

    if Global.ballY < Constant.FIELD_LENGTH/2:
        Forward.resetEachFrame()
        rAttacker.DecideNextAction()
        FWHead.DecideNextAction()        
        return

    me_x = Global.selfLoc.getX()
    me_y = Global.selfLoc.getY()
    #ballToGoalDist = HelpMath.getDistanceBetween( \
    #    Global.ballX, Global.ballY, \
    #    Constant.TARGET_GOAL_X, Constant.TARGET_GOAL_Y) 
    
    angleMeBallGoal = \
                    HelpMath.angleBetweenTwoPointsFromPivotPoint( \
            me_x, me_y, \
            Constant.TARGET_GOAL_X, Constant.TARGET_GOAL_Y, \
            Global.ballX, Global.ballY )

    distToGoal = HelpMath.getDistanceBetween(me_x, me_y,
                                             Constant.TARGET_GOAL_X,
                                             Constant.TARGET_GOAL_Y)


    MyTrack.DecideNextAction() # for head controlling

    if canDoKick() and distToGoal < 100:
        if isInRange(angleMeBallGoal, -KICK_MAX, -KICK_MIN):
            Kick.UPright()
        elif isInRange(angleMeBallGoal, KICK_MIN, KICK_MAX):
            Kick.UPleft()
    elif HelpTrack.inTargetGoalBox(Global.ballX, Global.ballY):
        # if ball in the goal box
        goalBoxKick(angleMeBallGoal)
    else:
        GrabTurnKick.DecideNextAction()
Esempio n. 2
0
def goalBoxKick(angleMeBallGoal):
    if not canDoKick():
        MyTrack.DecideNextAction()
    else:
        FACE_GOAL = 160
        if isInRange(angleMeBallGoal, -KICK_MIN, 0):
            rotateAboutBall(MyTrack.LEFT)
        elif isInRange(angleMeBallGoal, -KICK_MAX, -KICK_MIN):
            Kick.UPright()
        elif isInRange(angleMeBallGoal, -FACE_GOAL, -KICK_MAX):            
            rotateAboutBall(MyTrack.RIGHT)            
            
        elif isInRange(angleMeBallGoal, 0, KICK_MIN):
            rotateAboutBall(MyTrack.RIGHT)
        elif isInRange(angleMeBallGoal, KICK_MIN, KICK_MAX):
            Kick.UPleft()
        elif isInRange(angleMeBallGoal, KICK_MAX, FACE_GOAL):
            rotateAboutBall(MyTrack.LEFT)
        
        else: # if  < -FACE_GOAL or > FACE_GOAL
            WalkAction.setNormalWalk(5, 0, 0)
Esempio n. 3
0
def StillDoingGetBehind():

    global debugLed
    global AttackMode, LockDKDRegion
    global AllowLocaliseTimer, DisallowLocaliseTimer
    global AttackDistMem, AttackAngleMem, AttackDirMem
    ##~     global StandTimer

    debug = False

    ##~     if debug:
    ##~         print "", HelpLong.getStuckInfo()

    if AttackMode == Constant.GET_BEHIND_BALL:

        if debug:
            print ""
            print "In StillDoingGetBehind()"
            print "mode       %d   dkd-region     %d" % (AttackMode,
                                                         LockDKDRegion)
            print "allowTimer %d   disallowTimer  %d" % (AllowLocaliseTimer,
                                                         DisallowLocaliseTimer)
            print "radius %d,  angle %.2f,  dir %d" % (
                AttackDistMem, AttackAngleMem, AttackDirMem)
            ##~             print "AttackPosX %.2f,   AttackPosY %.2f" % (AttackPosX, AttackPosY)
            print "myh %.2f" % (Global.selfLoc.getHeading())

        # Break out the get behind if:
        # 1. u have done it, a fire paw kick case will catch it if on edges, and it should
        # 2. the ball rolls out far, then chase it rather than get behind
        # 3. the ball keeps rolling out

        if abs(
                HelpMath.normalizeAngle_180(Global.selfLoc.getHeading() -
                                            AttackAngleMem)) < 20:

            GetBehindBreakOutAction()

            if debug:
                print "break out, lined up: the h", Global.selfLoc.getHeading()
            return False

        if Global.ballD > 65:  # Ball has rolled out far away

            if debug:
                print "break out: ballD > 65", Global.ballD

            GetBehindBreakOutAction()
            return False

        if Global.lastForward < -3:

            GetBehindBreakOutAction()
            return False

        # Otherwise, continue getBehindBall, and additionally may do a kick.
        GetBehindBall.getBehindBall(AttackDistMem, AttackAngleMem,
                                    AttackDirMem, False, 60, 1.2)
        IndicatorAction.showFacePattern(debugLed)

        if (Global.ballD < 25 and LockDKDRegion != Constant.DKDBlank):
            Global.finalAction[Constant.AAForward] *= 0.7
            Global.finalAction[Constant.AALeft] *= 0.7
            Global.finalAction[Constant.AATurnCCW] *= 0.7

        # Check if ready to do a YouPanCake.
        if LockDKDRegion == Constant.DKDLeft and BallUnderChinForUpenn():

            debugLed = None
            LockDKDRegion = Constant.DKDBlank
            AttackMode = Constant.HOVER_TO_BALL
            setLocaliseTimer(0, 30)
            if debug:
                print "break out doing upenn"
            Kick.UPright()

        elif LockDKDRegion == Constant.DKDRight and BallUnderChinForUpenn():

            debugLed = None
            LockDKDRegion = Constant.DKDBlank
            AttackMode = Constant.HOVER_TO_BALL
            setLocaliseTimer(0, 30)
            Kick.UPleft()

            if debug:
                print "break out doing upenn"

        return True

    # then it must be HOVER_TO_BALL.
    else:
        return False