def perform(params=None): global gBirdToBall id(params) # ignore resetEachFrame() # Back off if stuck if hStuck.amIStuckForward(): hFWHead.DecideNextAction() return targetX, targetY, _rangeX = hWhere.getSupporterPos() selfX, selfY = Global.selfLoc.getPos() hFWHead.DecideNextAction() # If the attacker has grabbed, get out of the way if hTeam.hasTeammateGrabbedBall(): if getOutOfEveryonesWay(): return # Continue BOP if one is executing if sBirdOfPrey.isBirdOfPreyTriggering(): if sBirdOfPrey.birdTo == sBirdOfPrey.BIRD_TO_BALL: birdPos = (Global.ballX, Global.ballY) else: birdPos = (targetX, targetY) if sBirdOfPrey.perform(*birdPos) == Constant.STATE_EXECUTING: hFWHead.minPosVariance = 1 # look around more often hFWHead.DecideNextAction() return # Stay out of the shot line and away from robots. This is after the bird # since the bird is more important than most of these, and DodgyDog in # the bird should keep us clear if getOutOfEveryonesWay(): return # If I have lost the ball for a while, then find the ball. # Don't trust gps for a long time, because after a few frames, gps ball # will direct you to no where. It is better for the robot to go into find # ball mode. if Global.ballSource == Constant.GPS_BALL and \ Global.lostBall >= 2 * Constant.LOST_BALL_SCAN: Indicator.showFacePattern([5, 0, 0, 0, 5]) sFindBall.findBySpin() return # Move to supporter position supportBall() # Bird back to position if I am way in front if targetY < selfY - BIRD_TO_POS_THRESH: sBirdOfPrey.birdTo = sBirdOfPrey.BIRD_TO_POS if sBirdOfPrey.perform(targetX, targetY) == Constant.STATE_EXECUTING: return
def performDodge(): global gLastActionFrame, gLastDiagFrame, gDodgeCounter global gForward, gLeft gLastActionFrame = Global.frame obsFront = VisionLink.getNoObstacleInBox(-25, 100, 25, 20, Constant.MIN_VIS_OBSTACLE_BOX, Constant.OBS_USE_LOCAL) if gDodgeCounter > 0: gLastDiagFrame = Global.frame gDodgeCounter -= 1 Indicator.showFacePattern([1, 1, 1, 1, 1]) turnCCW = 0 if Global.vTGoal.isVisible(): turnCCW = Global.vTGoal.getHeading() elif Global.frame - gLastVisTGoalFrame < TRUST_VIS_GOAL_DURATION: turnCCW = gLastVisTGoal.getHeading() turnCCW = hMath.CLIP(turnCCW, 30) return perform(gForward, gLeft, turnCCW) elif hStuck.amIStuckForward(dodgeTime=0): gLastDiagFrame = Global.frame Indicator.showFacePattern([2, 2, 2, 2, 2]) forward = 0 left = 0 if hStuck.gStuckType == hStuck.STUCK_FWD_LEFT: left = -Action.MAX_LEFT elif hStuck.gStuckType == hStuck.STUCK_FWD_RIGHT: left = Action.MAX_LEFT # otherwise, stuck both. else: forward = -Action.MAX_FORWARD gForward = forward gLeft = left return perform(gForward, gLeft, 0) elif obsFront > MIN_OBS_TO_DODGE: gLastDiagFrame = Global.frame Indicator.showFacePattern([1, 1, 1, 1, 1]) gDodgeCounter = DODGE_DURATION left = 0 selfX, selfY = Global.selfLoc.getPos() # Decide which way to dodge. # If we can see best gap, dodge towards the best gap. if Global.vTGoal.isVisible(): minH, maxH = selectGap(gGapAimCount >= 2) if Global.vTGoal.isVisible() and minH != 0 and maxH != 0: # If we are within the best gap, don't dodge. padding = abs(maxH - minH) / 5.0 if minH < -padding and padding < maxH: gDodgeCounter = 0 return Constant.STATE_SUCCESS # Dodge left. if abs(minH) > abs(maxH): left = Action.MAX_LEFT # Otherwise, dodge right. else: left = -Action.MAX_LEFT # If you are in offensive half, # then always dodge towards the center of the field. elif selfY > Constant.FIELD_LENGTH / 2.0: if selfX > Constant.FIELD_WIDTH / 2.0: left = Action.MAX_LEFT else: left = -Action.MAX_LEFT # Otherwise, dodge towards outside? else: if selfX > Constant.FIELD_WIDTH / 2.0: left = hMath.getSign(Action.MAX_LEFT, selfX - Constant.FIELD_WIDTH / 3.0) else: left = hMath.getSign(Action.MAX_LEFT, selfX - 2.0 * Constant.FIELD_WIDTH / 3.0) gForward = 5 gLeft = left return perform(gForward, left, 0) else: return Constant.STATE_SUCCESS
def perform(params=None): global gGetOutOfTheBallCounter global gGetOutOfTheAttackerCounter global gGetOutOfTheCircleCounter global gMateLoc global gTargetPointReqAccuracy id(params) # ignore resetEachFrame() # Back of if stuck if hStuck.amIStuckForward(): hFWHead.DecideNextAction() return hFWHead.DecideNextAction() # If the attacker has grabbed, get out of the way # if hTeam.hasTeammateGrabbedBall(): # if getOutOfEveryonesWay(): # return # --------------------------------------------------------------- # Check if I need to get out of the way for the attacker first. targetH = hMath.normalizeAngle_0_360(Global.selfLoc.getHeading() + Global.ballH) if gGetOutOfTheBallCounter > 0: r = sGetOutOfTheWay.perform(Global.ballX,Global.ballY,\ Constant.TARGET_GOAL_X,Constant.TARGET_GOAL_Y,\ targetH,True) if r == Constant.STATE_EXECUTING: gGetOutOfTheBallCounter -= 1 Indicator.showFacePattern([0, 0, 2, 0, 0]) return gGetOutOfTheBallCounter = 0 if gGetOutOfTheAttackerCounter > 0: r = sGetOutOfTheWay.perform(Global.ballX,Global.ballY,\ gMateLoc.getX(),gMateLoc.getY(),\ targetH,True) if r == Constant.STATE_EXECUTING: gGetOutOfTheAttackerCounter -= 1 Indicator.showFacePattern([0, 0, 2, 0, 0]) return gGetOutOfTheAttackerCounter = 0 if gGetOutOfTheCircleCounter > 0: r = sGetOutOfTheWay.getOutOfTheCircle(Global.ballX, Global.ballY, targetH, True) if r == Constant.STATE_EXECUTING: gGetOutOfTheCircleCounter -= 1 Indicator.showFacePattern([0, 2, 0, 2, 0]) return gGetOutOfTheCircleCounter = 0 for i in Global.otherValidForwards: mate = Global.teamPlayers[i] if mate.isAttacker()\ and mate.getTimeToReachBall() < 3000: r = sGetOutOfTheWay.perform(Global.ballX,Global.ballY,\ Constant.TARGET_GOAL_X,Constant.TARGET_GOAL_Y,\ targetH) if r == Constant.STATE_EXECUTING: gGetOutOfTheBallCounter = GET_OUT_DURATION Indicator.showFacePattern([0, 0, 2, 0, 0]) return mateLoc = Global.teammatesLoc[i] gMateLoc = mateLoc.getCopy() r = sGetOutOfTheWay.perform(Global.ballX,Global.ballY,\ mateLoc.getX(),mateLoc.getY(),\ targetH) if r == Constant.STATE_EXECUTING: gGetOutOfTheAttackerCounter = GET_OUT_DURATION Indicator.showFacePattern([0, 0, 2, 0, 0]) return r = sGetOutOfTheWay.getOutOfTheCircle(Global.ballX, Global.ballY, targetH) if r == Constant.STATE_EXECUTING: gGetOutOfTheCircleCounter = GET_OUT_DURATION Indicator.showFacePattern([0, 2, 0, 2, 0]) return # --------------------------------------------------------------- # trigger BOP if i was doing it. if sBirdOfPrey.isBirdOfPreyTriggering(): # FIXME: Winger currently not in use so birding not updated if sBirdOfPrey.perform(Global.ballX, Global.ballY) == Constant.STATE_EXECUTING: return # trigger BOP when I am certain distance behind from the ball DEFENCE_OFFSET = 10.0 DEFENCE_ANGLE = 150.0 if sBirdOfPrey.areWeAboveTheLine(DEFENCE_OFFSET,DEFENCE_ANGLE,True, \ Global.ballX, Global.ballY): sBirdOfPrey.perform(Global.ballX, Global.ballY) return # If I have lost the ball for a while, then find the ball. if (Global.ballSource == Constant.GPS_BALL and Global.lostBall > 210)\ or (Global.ballSource == Constant.WIRELESS_BALL and Global.lostBall > 240): Indicator.showFacePattern([5, 0, 0, 0, 5]) sFindBall.perform() return doGetToTargetPoint()
def perform(params=None): VisionLink.startProfile("rAttacker.py") global gLastFrameCalled global gLastDecisionFunction global isGoal id(params) # ignore shouldIBeDodgy = gUseDodgyDog if gLastFrameCalled != Global.frame - 1: resetPerform() gLastFrameCalled = Global.frame ### Variable lighting challenge ### if Global.lightingChallenge and playMode: if Global.vBall.isVisible(): isGoal = False for pressSensor in range(1, 4, 1): # Used to react to back sensors if VisionLink.getPressSensorCount(pressSensor) > 8: print "It's a goal!!" isGoal = True if isGoal: VisionLink.resetBall(Constant.FIELD_WIDTH / 2.0, Constant.FIELD_LENGTH / 2.0, 0.0, 0.0) pos = Global.selfLoc.getPos() if (hMath.getDistanceBetween(pos[0], pos[1], Constant.FIELD_WIDTH / 2.0, Constant.FIELD_LENGTH / 2.0) < 50): sFindBall.perform() else: hTrack.stationaryLocalise() hTrack.saGoToTarget(Constant.FIELD_WIDTH / 2.0, Constant.FIELD_LENGTH / 2.0) return else: pass # perform normal attacker elif Global.lightingChallenge: ObsMapping() return ### End variable lighting challenge ### ### Penalty Shooter #### if Global.penaltyShot: if Global.frame - Global.firstPlayFrame < 90: hTrack.stationaryLocalise() return elif Global.frame - Global.firstPlayFrame < 115: sFindBall.perform(True) return #print "rAttacker frame", # Last man attacker can block # if not hTeam.amIFurthestBack(ignoreRoles = []): # print "not furthest back" # elif sGrab.grabbingCount > 0: # print "grabbing count", sGrab.grabbingCount # elif sGrab.isGrabbed: # print "grabbed" # elif Global.frame - sGrabDribble.gLastActionFrame < 60: # print "grabdribbleaction", sGrabDribble.gLastActionFrame ## if hTeam.amIFurthestBack(ignoreRoles = []) \ ## and not sGrab.grabbingCount > 0 \ ## and not sGrab.isGrabbed \ ## and hMath.getTimeElapsed(sGrab.gLastGrabTime, VisionLink.getCurrentTime()) > 7000 \ ## and not Global.penaltyShot \ ## and Global.frame - sGrabDribble.gLastActionFrame > 60 \ ## and Global.selfLoc.getHeading() < 180 \ ## and Global.selfLoc.getY() < Constant.FIELD_LENGTH * 0.7: ## #print __name__, "candidate block" ## #_, _, speed, dirDegrees, _, _ = VisionLink.getGPSBallVInfo(Constant.CTLocal) ## #print "speed", speed ## # This speed really needs to be 4.5 to remove all noise but then it ## # nearly never blocks. I'm under pressure to keep it possible in the ## # face of all the other checks above, hence 4 ## if sBlock.checkThenBlock(onlyVisualBall = True, minBallSpeed = 3, ## minDist = 40, maxDist = 80, ## bothSides = False, dontBlockCentre = True): ## print __name__, hMath.getTimeElapsed(sGrab.gLastGrabTime, ## VisionLink.getCurrentTime()) ## print __name__, Global.frame, "blocking, gLastActionFrame =", sGrabDribble.gLastActionFrame ## print ## return # Back off if stuck if hStuck.amIStuckForward()\ and Global.ballD > 200\ and Global.gpsLocalBall.getDistance() > 200\ and not sGrab.isGrabbed\ and sGrab.grabbingCount == 0\ and Global.frame - sGrab.gLastApproachFrame >= 5\ and (not Global.penaltyShot)\ and (not Global.lightingChallenge): sFindBall.perform(True) return # Don't go into own goal box if hWhere.ballInOwnGoalBox(0)\ and (not sGrab.isGrabbed)\ and sGrab.grabbingCount == 0\ and (not Global.penaltyShot)\ and (not Global.lightingChallenge): #print "Ball in goal box" #print "avoiding" doAvoidGoalBox() hFWHead.DecideNextAction() return # no dodgy if not shouldIEndActivelyLocalise()\ or shouldIActivelyLocalise(): #print "localising" doActivelyLocalise() elif shouldIKick(): #shouldIBeDodgy = False #Really? #print "kicking" doKick() elif Global.lightingChallenge and shouldIGoToCenter(): doGotoCenter() else: #print "tracking" doTrackBall() # Use dodgy dog if required fwdCmd = Action.finalValues[Action.Forward] shouldIBeDodgy = shouldIBeDodgy \ and (not sGrab.isGrabbed) \ and sGrab.grabbingCount == 0 \ and Global.frame - sGrab.gLastApproachFrame >= 5 \ and Global.ballD >= sGrab.CLOSE_DIST \ and Global.frame - sFindBall.gLastSpinFrame >= 15 \ and Global.frame - sGetBehindBall.gLastCalledFrame >= 5 \ and fwdCmd > Action.MAX_SKE_FWD_SPD/2 \ and fwdCmd > abs(Action.finalValues[Action.Left]) \ and sDodgyDog.shouldIBeDodgyToBall() if shouldIBeDodgy: #print "and dodging" sDodgyDog.dodgyDogToBall() VisionLink.stopProfile("rAttacker.py")
def perform(params = None): global gTargetPointReqAccuracy global gBirdToBall#, gBirdPos id(params) # ignore resetEachFrame() # Back off if stuck if hStuck.amIStuckForward() and not hWhere.selfInOwnGoalBox(15): hFWHead.DecideNextAction() return targetX, targetY = hWhere.getDefenderPos() selfX, selfY = Global.selfLoc.getPos() hFWHead.DecideNextAction() # If the attacker has grabbed, get out of the way if hTeam.hasTeammateGrabbedBall(): if getOutOfEveryonesWay(): return # Continue BOP if already doing one if sBirdOfPrey.isBirdOfPreyTriggering(): if sBirdOfPrey.birdTo == sBirdOfPrey.BIRD_TO_BALL: birdPos = (Global.ballX, Global.ballY) else: # BIRD_TO_POS birdPos = (targetX, targetY) # If there are no robots between (x) us and the ball defender can use # a tighter curve birdAngle = 40 for i in Global.otherValidForwards: if Global.teammatesLoc[i].getY() > Global.ballY \ and Global.ballX < Global.teammatesLoc[i].getX() \ < Global.selfLoc.getX(): birdAngle = 45 elif Global.teammatesLoc[i].getY() > Global.ballY \ and Global.selfLoc.getX() < Global.teammatesLoc[i].getX() \ < Global.ballX: birdAngle = 45 if sBirdOfPrey.perform(birdPos[0], birdPos[1], birdAngle)\ == Constant.STATE_EXECUTING: # Can we do better than this (supporter too)? Need to see obstacles hFWHead.minPosVar = 1 # localise more often hFWHead.DecideNextAction() return # Make sure we're not obstructing teammates. This is less important than # the bird, but hopefully DodgyDog in the bird will keep us clear. if getOutOfEveryonesWay(): return # Bird back to position if I am way in front and not close to ball if targetY < selfY - BIRD_TO_POS_THRESH and Global.ballD > 70: sBirdOfPrey.birdTo = sBirdOfPrey.BIRD_TO_POS if sBirdOfPrey.perform(targetX, targetY) == Constant.STATE_EXECUTING: return # trigger BOP when I am certain distance in front of the ball, but not if # defender position is in front of the ball anyway #DEFENCE_OFFSET = 10.0 #DEFENCE_ANGLE = 150.0 #if targetY < Global.ballY < selfY and \ # sBirdOfPrey.areWeAboveTheLine(DEFENCE_OFFSET, DEFENCE_ANGLE, \ # True, Global.ballX, Global.ballY): # sBirdOfPrey.birdTo = sBirdOfPrey.BIRD_TO_BALL # if sBirdOfPrey.perform(Global.ballX, Global.ballY) == Constant.STATE_EXECUTING: # return sBirdOfPrey.birdTo = None # If I have lost the ball for a while, then find the ball. if Global.ballSource == Constant.GPS_BALL and Global.lostBall > 150: Indicator.showFacePattern([5,0,0,0,5]) findBallDefender() return doGetToTargetPoint(targetX, targetY) # Check if I need to back off, because of obstacle in front of me. """
def readyMatchPlaying(): global debug, timer, inStartPos, isFacingTargetGoal, getOutOfGoalDirection, lastTurningDirection, gUseDodgyDog selfX = Global.selfLoc.getPos()[0] selfY = Global.selfLoc.getPos()[1] selfH = Global.selfLoc.getHeading() Action.closeMouth() # Player number detection. The goalie *must* be player one. Freak if not. if Global.myPlayerNum == 1 and not Global.isGoalieBehaviour: Action.kick(Action.ChestPushWT) return elif Global.myPlayerNum != 1 and Global.isGoalieBehaviour: Action.kick(Action.ChestPushWT) return if not Global.penaltyShot and hStuck.amIStuckForward(dodgeTime=9): return # Need to move toward the field ? if shouldITurnTowardTheField(): Action.walk(0, 0, getOutOfGoalDirection) # Am I in the correct starting position and facing toward the target goal # (or facing upward)? if inStartPos and isFacingTargetGoal: # use the ball distance to try to move as close as the centre circle #if VisionLink.getKickOffTeam() == VisionLink.getTeamColor() and \ # useBallDistanceSetKickOffPosition(): # return # Do I need to move to a new position if I am in a wrong position? if Debug.allowReadyMove: if hMath.getDistanceBetween(selfX, selfY, \ Global.kickOffPos[0], Global.kickOffPos[1]) \ > Constant.POS_OFFSET_OUT_KICK: inStartPos = False return # Turn myself if I am not facing toward the desired heading. At the # moment 90 is the desired heading angle. # TODO: Accoiding to different positions, different desired heading. if abs(hMath.normalizeAngle_180(selfH - 90)) > \ Constant.READY_HEADING_OFFSET: isFacingTargetGoal = False return inPositionAndFacingTargetLocalise() return # Am I in the correct starting position but not facing the target goal (or # facing upward)? if inStartPos: # Do I need to move to a new position if I am in a wrong position? if Debug.allowReadyMove: if hMath.getDistanceBetween(selfX, selfY, \ Global.kickOffPos[0], Global.kickOffPos[1])\ > Constant.POS_OFFSET_OUT_KICK: inStartPos = False return # Is me facing toward the target goal now? If I am facing the right # direction, then better reset the turning direction variable. if abs(selfH - 90) < Constant.READY_HEADING_OFFSET: isFacingTargetGoal = True lastTurningDirection = None # If I am not facing toward the target goal, then turn slowly without # moving forward or left. else: # Determine the best turning direction and stick with it. if lastTurningDirection == None: # I haven't determine my turning direction yet. Determine now. if Global.selfLoc.getHeading() >= 270 or \ Global.selfLoc.getHeading() <= 90: # -90 <= angle <= 90 lastTurningDirection = Constant.dANTICLOCKWISE if Debug.readyDebug: print "Anti-clockwise direction!" else: # 90 < angle < 270 lastTurningDirection = Constant.dCLOCKWISE if Debug.readyDebug: print "Clockwise direction!" if lastTurningDirection == Constant.dCLOCKWISE: Action.walk(0, 0, -15) else: Action.walk(0, 0, 15) return # Phase1: I am not in the correct starting position. First step for me is # to stand still and beacon localise. if timer <= INITIAL_LOCALISE_TIME: if Debug.readyDebug and timer == 1: print "Phase 1 has been executed!" if timer <= 79: Global.kickOffState = Constant.NOTDECIDED Action.stopLegs() # Need to move toward the field ? if shouldITurnTowardTheField(): Action.walk(0, 0, getOutOfGoalDirection) hTrack.stationaryLocalise() timer = timer + 1 if timer >= 80: # Now decide my starting kickoff position dynamically now. if hTeam.robotAlive() != 1: getMyKickOffPosition() return lastTurningDirection = None # Now we can either use the static result from getMyKickOffPosition() or # dynamically calculated again, if hTeam.robotAlive() != 1: getMyKickOffPosition() # If I am unable to find the kickoff position earlier (possibly because of # wirless problem), then probably only 2 or less robots are on the field # now. Notice that I can't be a goalie in this case. I must be either # player 2 forward or player 3 forward. Not player 4 forward because it # determines its kicking position without worrying about any other # forwards. if Global.kickOffState == Constant.NOTDECIDED or Global.kickOffPos == None: alive = hTeam.forwardAlive() if alive >= 3: if Debug.readyDebug: print "Something went wrong, three forwards without assigning! Automatical assign!" ##~ # This case may happen in friendly games where not all four robots are present. ##~ # Firstly if there are three forwards alive, but I am not assigned a position. Then: ##~ # 1. I can't be player 1 because this is a goalie ##~ # 2. I can't be player number 4 forward. ##~ # So I must be either player 2 or player 3 forward. ##~ # ##~ # If I am a player 3, then probably the three forwards are: 1, 2, 3 ##~ # If I am a player 2, then probably the three forwards are: 1, 2, 4 ##~ if Global.myPlayerNum == 3: _, Global.kickOffPos, _, _ = getAllPossibleKickingOffPosition() Global.kickOffState = Constant.DECIDEPOSITION_B elif Global.myPlayerNum == 2: # Try to get player 4's decision. if Global.teamPlayers[3].getCounter() > 0: position = Global.teamPlayers[3].getKickedOff() if position == Constant.DECIDEPOSITION_A: determineMyKickingOffPositionIfOnlyMeForwardAlive( False, True, True) elif position == Constant.DECIDEPOSITION_B: determineMyKickingOffPositionIfOnlyMeForwardAlive( True, False, True) elif position == Constant.DECIDEPOSITION_C: determineMyKickingOffPositionIfOnlyMeForwardAlive( True, True, False) else: Debug.goAndMakeTraceBack() return else: # Well, lets wait. return elif alive == 2: if Debug.readyDebug: print "Only two alive case - What the hell?" if Global.myPlayerNum == 2: Global.kickOffPos, b, c, d = getAllPossibleKickingOffPosition() Global.kickOffState = Constant.DECIDEPOSITION_A elif Global.myPlayerNum == 3: a, Global.kickOffPos, c, d = getAllPossibleKickingOffPosition() Global.kickOffState = Constant.DECIDEPOSITION_B else: if Debug.readyDebug: print "Something went wrong, I am not player 2 or 3, why not decided position?" elif alive == 1: if Debug.readyDebug: print "Only one alive case!" a, b, c, d = getAllPossibleKickingOffPosition() if Global.myPlayerNum == 2: Global.kickOffPos = a Global.kickOffState = Constant.DECIDEPOSITION_A elif Global.myPlayerNum == 3: Global.kickOffPos = b Global.kickOffState = Constant.DECIDEPOSITION_B elif Global.myPlayerNum == 4: Global.kickOffPos = c Global.kickOffState = Constant.DECIDEPOSITION_C else: # Goalie Global.kickOffPos = d Global.kickOffState = Constant.DECIDEPOSITION_D # At this point the kicking off position must been determined. showKickOffHeadIndicator() # Set the initial roles based on position if Global.kickOffPos == P_REC_CENTRE: Global.myRole = Constant.ATTACKER elif Global.kickOffPos == P_REC_LEFT_WIDE \ or Global.kickOffPos == P_REC_RIGHT_WIDE: Global.myRole = Constant.DEFENDER elif Global.kickOffPos == P_REC_RIGHT_CLOSE \ or Global.kickOffPos == P_REC_LEFT_CLOSE: Global.myRole = Constant.SUPPORTER elif Global.kickOffPos == P_KICK_KICKER: Global.myRole = Constant.ATTACKER elif Global.kickOffPos == P_KICK_LEFT_BACK \ or Global.kickOffPos == P_KICK_RIGHT_BACK: Global.myRole = Constant.DEFENDER elif Global.kickOffPos == P_KICK_RIGHT_FORWARD \ or Global.kickOffPos== P_KICK_LEFT_FORWARD: Global.myRole = Constant.SUPPORTER # Testing the kickoff position without actually moving them. ##~ if Debug.readyDebug and Debug.testKickOffPosition: ##~ if Global.kickOffState == None: ##~ print "My kickoff position is: None %f" %Global.myPlayerNum ##~ else: ##~ print "My player number: %f" %Global.myPlayerNum ##~ print "My kickoff position is: %f" %Global.kickOffState ##~ return # Move from phase 2 to phase 3. Am I in the correct starting position now? dist = hMath.getDistanceBetween(selfX, selfY, Global.kickOffPos[0], Global.kickOffPos[1]) if dist < Constant.POS_OFFSET_IN_KICK: # Ok, I am in the correct starting position. I stop myself now. Action.stopLegs() inStartPos = True # Phase2: I need to walk to my starting position. Localise by moving the # head while I move. else: if dist < sDodgyDog.MIN_DODGY_TARGET_DIST: hTrack.stationaryLocalise() else: # Move head less while dodgy to see obstacles hTrack.stationaryLocalise(5, 30, -30) if gUseDodgyDog and \ sDodgyDog.shouldIBeDodgy(Global.kickOffPos[0], Global.kickOffPos[1], True, Constant.POS_OFFSET_OUT_KICK): if sDodgyDog.dodgyDogTo( Global.kickOffPos[0], Global.kickOffPos[1], True, Constant.POS_OFFSET_OUT_KICK) == Constant.STATE_SUCCESS: inStartPos = True else: movingAction()