コード例 #1
0
ファイル: GoalieSaveStates.py プロジェクト: thiggins/nbites
def goalieSave(player):

    brain = player.brain
    ball = brain.ball

    if player.firstFrame():
        player.stopWalking()
        brain.tracker.trackBallFixedPitch()
        player.isSaving = True

    if helper.shouldSave(player):
        brain.tracker.stopHeadMoves()
        brain.fallController.enableFallProtection(False)
        if TESTING:
            print "Saving because"
            print "Ball.relVelX is" + str(ball.loc.relVelX)
            print "And Ball.heat is" + str(ball.vis.heat)
            if helper.shouldSaveRight(player):
                return player.goNow('testSaveRight')
            elif helper.shouldSaveLeft(player):
                return player.goNow('testSaveLeft')
            else:
                return player.goNow('testSaveCenter')
        else:
            if helper.shouldSaveRight(player):
                return player.goNow('saveRight')
            if helper.shouldSaveLeft(player):
                return player.goNow('saveLeft')
            else:
                return player.goNow('saveCenter')

    return player.stay()
コード例 #2
0
ファイル: GoalieSaveStates.py プロジェクト: nerkis/nbites
def goalieSave(player):

    brain = player.brain
    ball = brain.ball

    if player.firstFrame():
        player.stopWalking()
        brain.tracker.trackBall()
        player.isSaving = True

    if helper.shouldSave(player):
        brain.tracker.stopHeadMoves()
        brain.fallController.enableFallProtection(False)
        if TESTING:
            print "Saving because"
            print "Ball.relVelX is" + str(ball.loc.relVelX)
            print "And Ball.heat is" + str(ball.vis.heat)
            if helper.shouldSaveRight(player):
                return player.goNow("testSaveRight")
            elif helper.shouldSaveLeft(player):
                return player.goNow("testSaveLeft")
            else:
                return player.goNow("testSaveCenter")
        else:
            if helper.shouldSaveRight(player):
                return player.goNow("saveRight")
            if helper.shouldSaveLeft(player):
                return player.goNow("saveLeft")
            else:
                return player.goNow("saveCenter")

    return player.stay()
コード例 #3
0
def goaliePosition(player):
    """
    Have the robot navigate to the position reported to it from playbook
    """
    nav = player.brain.nav
    my = player.brain.my
    ball = player.brain.ball
    heading = None

    if player.firstFrame():
        player.isPositioning = True
        player.isChasing = False
        player.isSaving = False
        nav.positionPlaybook()

    if ball.dist >= goalCon.ACTIVE_LOC_THRESH:
        player.brain.tracker.activeLoc()
    else:
        player.brain.tracker.trackBall() 

    if player.brain.nav.isStopped():
        if goalTran.shouldPositionLeft(player):
            player.goNow('goaliePositionLeft')

        elif goalTran.shouldPositionRight(player):
            player.goNow('goaliePositionRight')

    return player.stay()
コード例 #4
0
ファイル: GoalieTestStates.py プロジェクト: bbellon/nbites
def testShouldPositionRight(player):
    if player.counter % 100 == 0:
        if goalTran.shouldPositionRight(player):
            print "position right"
        elif goalTran.shouldPositionLeft(player):
            print "position left"
        elif goalTran.shouldPositionCenter(player):
            print "postion center"

    return player.stay()
コード例 #5
0
ファイル: GoalieSaveStates.py プロジェクト: bbellon/nbites
def goaliePickSave(player): 
    player.brain.fallController.enableFallProtection(False)

    if helper.shouldSaveRight(player):
        return player.goNow('saveRight')
    elif helper.shouldSaveLeft(player):
        return player.goNow('saveLeft')
    elif helper.shouldSaveCenter(player):
        return player.goNow('saveCenter')

    return player.stay()
コード例 #6
0
def goaliePositionForSave(player):
    if player.firstFrame():
        player.stopWalking()
        player.brain.tracker.trackBall()

    strafeDir = helper.strafeDirForSave(player)
    if strafeDir == -1:
        helper.strafeRightSpeed(player)
    elif strafeDir == 1:
        helper.strafeLeftSpeed(player)
    else:
        player.stopWalking()

    return player.stay()
コード例 #7
0
def goaliePositionForSave(player):
    if player.firstFrame():
        player.stopWalking()
        player.brain.tracker.trackBall()

    strafeDir = helper.strafeDirForSave(player)
    if strafeDir == -1:
        helper.strafeRightSpeed(player)
    elif strafeDir == 1:
        helper.strafeLeftSpeed(player)
    else:
        player.stopWalking()

    return player.stay()
コード例 #8
0
ファイル: GoalieSaveStates.py プロジェクト: thiggins/nbites
def holdLeftSave(player):
    if helper.shouldHoldSave(player):
        return player.stay()
    else:
        return player.goLater('rollOutLeft')

    return player.stay()
コード例 #9
0
def testSaveDecision(player):
    ball = player.brain.ball

    if goalTran.shouldSave(player):
        return player.goNow('goalieSave')

    return player.stay()
コード例 #10
0
def testSaveDecision(player):
    ball = player.brain.ball

    if goalTran.shouldSave(player):
        return player.goNow('goalieSave')

    return player.stay()
コード例 #11
0
def squatPosition(player):
    brain = player.brain
    position = brain.play.getPosition()
    nav = brain.nav
    my = brain.my

    if player.firstFrame():
        player.changeOmniGoToCounter = 0
        player.isChasing = False
        player.squatting = False

    if brain.ball.x >= constants.ACTIVE_LOC_THRESH:
        brain.tracker.activeLoc()
    else:
        brain.tracker.trackBall()

    useOmni = helper.useOmni(player)
    changedOmni = False

    ball = brain.ball
    bearing = None

    if (not nav.atDestinationGoalie() or
        not nav.atHeading()):
        if not useOmni:
            nav.goTo((PBConstants.GOALIE_HOME_X, PBConstants.GOALIE_HOME_Y,\
                          NogginConstants.OPP_GOAL_HEADING))
        else:
            nav.omniGoTo((PBConstants.GOALIE_HOME_X, PBConstants.GOALIE_HOME_Y,\
                              NogginConstants.OPP_GOAL_HEADING))
    else:
        player.stopWalking()
        return player.goLater("squat")

    return player.stay()
コード例 #12
0
ファイル: GoalieSaveStates.py プロジェクト: thiggins/nbites
def holdCenterSave(player):
    if helper.shouldHoldSave(player):
        return player.stay()
    else:
        return player.goLater('postCenterSave')

    return player.stay()
コード例 #13
0
def positionForGoalieKick(player):
    if player.firstFrame():
        player.brain.tracker.lookStraightThenTrack()
        if clearBall.ballSide == RIGHT:
            player.kick = kicks.RIGHT_SHORT_STRAIGHT_KICK
        else:
            player.kick = kicks.LEFT_SHORT_STRAIGHT_KICK
        ball = player.brain.ball
        positionForGoalieKick.kickPose = RelRobotLocation(ball.rel_x - player.kick.setupX,
                                    ball.rel_y - player.kick.setupY,
                                    0)
        positionForGoalieKick.speed = nav.GRADUAL_SPEED

        player.brain.nav.goTo(positionForGoalieKick.kickPose,
                                            speed = positionForGoalieKick.speed,
                                            precision = nav.CLOSE_ENOUGH)
    ball = player.brain.ball
    positionForGoalieKick.kickPose = RelRobotLocation(ball.rel_x - player.kick.setupX,
                                    ball.rel_y - player.kick.setupY,
                                    0)
    player.brain.nav.updateDest(positionForGoalieKick.kickPose)

    if GoalieTransitions.ballReadyToKick(player, positionForGoalieKick.kickPose):
        player.brain.nav.stand()
        return player.goNow('kickBall')

    return Transition.getNextState(player, positionForGoalieKick)
コード例 #14
0
ファイル: ChaseBallStates.py プロジェクト: bbellon/nbites
def approachBall(player):
    """
    Once we are aligned with the ball, approach it
    """
    # Switch to other states if we should
    if player.penaltyKicking and \
           player.brain.ball.inOppGoalBox():
        return player.goNow('penaltyBallInOppGoalbox')
    elif player.brain.tracker.activeLocOn:
        if transitions.shouldScanFindBallActiveLoc(player):
            return player.goLater('scanFindBall')
    elif transitions.shouldScanFindBall(player):
        return player.goLater('scanFindBall')
    elif player.brain.play.isRole(GOALIE) and goalTran.dangerousBall(player):
        return player.goNow('approachDangerousBall')
    elif transitions.shouldDribble(player):
        return player.goNow('dribble')
    elif transitions.shouldSpinToBallClose(player):
        return player.goNow('spinToBallClose')
    elif transitions.shouldStopBeforeKick(player):
        return player.goNow('stopBeforeKick')
    elif transitions.shouldPositionForKick(player):
        return player.goNow('decideKick')

    if player.firstFrame():
        player.brain.nav.chaseBall()
        player.hasAlignedOnce = False

    player.brain.tracker.trackBall()

    return player.stay()
コード例 #15
0
ファイル: GoalieSaveStates.py プロジェクト: gnmerritt/nbites
def holdRightSave(player):
    if helper.shouldHoldSave(player):
        return player.stay()
    else:
        return player.goLater('rollOutRight')

    return player.stay()
コード例 #16
0
ファイル: GoalieSaveStates.py プロジェクト: nerkis/nbites
def holdLeftSave(player):
    if helper.shouldHoldSave(player):
        return player.stay()
    else:
        return player.goLater("rollOutLeft")

    return player.stay()
コード例 #17
0
ファイル: GoalieSaveStates.py プロジェクト: nerkis/nbites
def testSaveCenter(player):
    if player.firstFrame():
        player.executeMove(SweetMoves.GOALIE_TEST_CENTER_SAVE)
    if player.counter > goalCon.TEST_SAVE_WAIT and not helper.shouldHoldSave(player):
        player.executeMove(SweetMoves.INITIAL_POS)
        return player.goNow("doneSaving")
    return player.stay()
コード例 #18
0
ファイル: GoalieSaveStates.py プロジェクト: nerkis/nbites
def holdCenterSave(player):
    if helper.shouldHoldSave(player):
        return player.stay()
    else:
        return player.goLater("postCenterSave")

    return player.stay()
コード例 #19
0
def positionForGoalieKick(player):
    if player.firstFrame():
        player.brain.tracker.lookStraightThenTrack()
        if clearBall.ballSide == RIGHT:
            player.kick = kicks.RIGHT_SHORT_STRAIGHT_KICK
        else:
            player.kick = kicks.LEFT_SHORT_STRAIGHT_KICK
        ball = player.brain.ball
        positionForGoalieKick.kickPose = RelRobotLocation(ball.rel_x - player.kick.setupX,
                                    ball.rel_y - player.kick.setupY,
                                    0)
        print("Kickpose:", positionForGoalieKick.kickPose.relX, positionForGoalieKick.kickPose.relY)
        positionForGoalieKick.speed = nav.GRADUAL_SPEED

        player.brain.nav.goTo(positionForGoalieKick.kickPose,
                                            speed = positionForGoalieKick.speed,
                                            precision = nav.CLOSE_ENOUGH)
    ball = player.brain.ball
    positionForGoalieKick.kickPose = RelRobotLocation(ball.rel_x - player.kick.setupX,
                                    ball.rel_y - player.kick.setupY,
                                    0)
    player.brain.nav.updateDest(positionForGoalieKick.kickPose)

    if GoalieTransitions.ballReadyToKick(player, positionForGoalieKick.kickPose):
        player.brain.nav.stand()
        print("Kickpose:", positionForGoalieKick.kickPose.relX, positionForGoalieKick.kickPose.relY)
        return player.goNow('kickBall')

    return Transition.getNextState(player, positionForGoalieKick)
コード例 #20
0
ファイル: GoalieSaveStates.py プロジェクト: gnmerritt/nbites
def testSaveLeft(player):
    if player.firstFrame():
        player.executeMove(SweetMoves.GOALIE_TEST_DIVE_LEFT)
    if(player.counter > goalCon.TEST_SAVE_WAIT and
        not helper.shouldHoldSave(player)):
        player.executeMove(SweetMoves.INITIAL_POS)
        return player.goNow('doneSaving')
    return player.stay()
コード例 #21
0
def testInBox(player):
    if player.counter % 100 == 0:
        if goalTran.goalieInBox(player):
            print "in"
        else:
            print "out"

    return player.stay()
コード例 #22
0
def testDangerousBall(player):
    if player.counter % 100 == 0:
        if goalTran.dangerousBall(player):
            print "dangerous"
        else:
            print "not dangerous"

    return player.stay()
コード例 #23
0
ファイル: GoalieSaveStates.py プロジェクト: thiggins/nbites
def testSaveCenter(player):
    if player.firstFrame():
        player.executeMove(SweetMoves.GOALIE_TEST_CENTER_SAVE)
    if (player.counter > goalCon.TEST_SAVE_WAIT
            and not helper.shouldHoldSave(player)):
        player.executeMove(SweetMoves.INITIAL_POS)
        return player.goNow('doneSaving')
    return player.stay()
コード例 #24
0
def testInBox(player):
    if player.counter % 100 == 0:
        if goalTran.goalieInBox(player):
            print "in"
        else:
            print "out"

    return player.stay()
コード例 #25
0
def testDangerousBall(player):
    if player.counter % 100 == 0:
        if goalTran.dangerousBall(player):
            print "dangerous"
        else:
            print "not dangerous"

    return player.stay()
コード例 #26
0
ファイル: GoalieTestStates.py プロジェクト: bbellon/nbites
def testStopChase(player):
    player.isChasing = True

    if goalTran.shouldStopChase(player):
        print "stop"
    else:
        print "not stopping"

    return player.stay()
コード例 #27
0
ファイル: GoalieTestStates.py プロジェクト: bbellon/nbites
def testChase(player):
    player.isSaving = False
    player.penaltyKicking = False

    if goalTran.shouldChase(player):
        print "chase"
    else:
        print "staying"

    return player.stay()
コード例 #28
0
ファイル: GoalieChanges.py プロジェクト: bbellon/nbites
def goalieStateChoice(player):
    ball = player.brain.ball

    # for simplicity to start off with we just want the goalie to chase
    # the ball as long as it is close enough and it isnt dangerous

    if player.isChasing:
        if goalTran.shouldStopChase(player):
            return "goaliePosition"
        else:
            return player.currentState

    if player.isPositioning:
        if goalTran.outOfPosition(player):
            return player.currentState
        elif goalTran.shouldChase(player):
            return "goalieChase"

    return player.currentState
コード例 #29
0
def goalieOutOfPosition(player):
    nav = player.brain.nav
    if helper.useFarPosition(player):
        player.brain.tracker.activeLoc()
    else:
        player.brain.tracker.trackBall()

    position = player.brain.play.getPosition()
    if player.firstFrame() or\
            nav.destX != position[0] or nav.destY != position[1]:
        nav.omniGoTo(position)

    if helper.useClosePosition(player):
        return player.goLater('goaliePositionBallClose')
    if nav.isStopped() and player.counter > 0:
        player.framesFromCenter = 0
        player.stepOffCenter = 0
        return player.goLater('goaliePosition')

    return player.stay()
コード例 #30
0
ファイル: ChaseBallStates.py プロジェクト: Lrosias/nbites
def chase(player):
    """
    Super State to determine what to do from various situations
    """
    if transitions.shouldFindBall(player):
        return player.goNow('findBall')

    if player.brain.play.isRole(GOALIE) and goalTran.dangerousBall(player):
        return player.goNow('approachDangerousBall')

    else:
        return player.goNow('positionForKick')
コード例 #31
0
def goaliePositionForSave(player):
    if player.firstFrame():
        player.stopWalking()
        player.brain.tracker.trackBall()

    strafeDir = helper.strafeDirForSave(player)
    if fabs(strafeDir) > 0:
        player.setWalk(0, constants.STRAFE_SPEED * MyMath.sign(strafeDir), 0)
    else:
        player.stopWalking()

    return player.stay()
コード例 #32
0
ファイル: ChaseBallStates.py プロジェクト: thiggins/nbites
def chase(player):
    """
    Super State to determine what to do from various situations
    """
    if transitions.shouldFindBall(player):
        return player.goNow('findBall')

    if player.brain.play.isRole(GOALIE) and goalTran.dangerousBall(player):
        return player.goNow('approachDangerousBall')

    else:
        return player.goNow('spinToBall')
コード例 #33
0
ファイル: ChaseBallStates.py プロジェクト: iris-xx/nao-man
def approachBallWalk(player):
    """
    Method that is used by both approach ball and dribble
    We use things as to when we should leave and how we should walk
    """

    if player.brain.playbook.role != pbc.GOALIE:
        if transitions.shouldNotGoInBox(player):
            return player.goLater('ballInMyBox')
        elif transitions.shouldChaseAroundBox(player):
            return player.goLater('chaseAroundBox')
        elif transitions.shouldApproachBallWithLoc(player):
            return player.goNow('approachBallWithLoc')
        elif transitions.shouldTurnToBall_ApproachBall(player):
            return player.goLater('turnToBall')
        elif not player.brain.tracker.activeLocOn and \
                transitions.shouldScanFindBall(player):
            return player.goLater('scanFindBall')
        elif player.brain.tracker.activeLocOn and \
                transitions.shouldScanFindBallActiveLoc(player):
            return player.goLater('scanFindBall')
        elif transitions.shouldAvoidObstacleDuringApproachBall(player):
            return player.goLater('avoidObstacle')

    # Determine our speed for approaching the ball
    ball = player.brain.ball
    if player.brain.playbook.role == pbc.GOALIE and goalTran.dangerousBall(player):
        return player.goNow('approachDangerousBall')

    if ball.dist < constants.APPROACH_WITH_GAIN_DIST:
        sX = MyMath.clip(ball.dist*constants.APPROACH_X_GAIN,
                         constants.MIN_APPROACH_X_SPEED,
                         constants.MAX_APPROACH_X_SPEED)
    else :
        sX = constants.MAX_APPROACH_X_SPEED

    # Determine the speed to turn to the ball
    sTheta = MyMath.clip(ball.bearing*constants.APPROACH_SPIN_GAIN,
                         -constants.APPROACH_SPIN_SPEED,
                         constants.APPROACH_SPIN_SPEED)
    # Avoid spinning so slowly that we step in place
    if fabs(sTheta) < constants.MIN_APPROACH_SPIN_MAGNITUDE:
        sTheta = 0.0

    # Set our walk towards the ball
    if ball.on:
        player.setSpeed(sX,0,sTheta)

    return player.stay()
コード例 #34
0
def approachBallWalk(player):
    """
    Method that is used by both approach ball and dribble
    We use things as to when we should leave and how we should walk
    """

    if not player.brain.play.isRole(GOALIE):
        if transitions.shouldNotGoInBox(player):
            return player.goLater('ballInMyBox')
        elif transitions.shouldChaseAroundBox(player):
            return player.goLater('chaseAroundBox')
        elif transitions.shouldApproachBallWithLoc(player):
            return player.goNow('approachBallWithLoc')
        elif transitions.shouldTurnToBall_ApproachBall(player):
            return player.goLater('turnToBall')
        elif not player.brain.tracker.activeLocOn and \
                transitions.shouldScanFindBall(player):
            return player.goLater('scanFindBall')
        elif player.brain.tracker.activeLocOn and \
                transitions.shouldScanFindBallActiveLoc(player):
            return player.goLater('scanFindBall')
        elif transitions.shouldAvoidObstacleDuringApproachBall(player):
            return player.goLater('avoidObstacle')

    # Determine our speed for approaching the ball
    ball = player.brain.ball
    if player.brain.play.isRole(GOALIE) and goalTran.dangerousBall(player):
        return player.goNow('approachDangerousBall')

    if ball.dist < constants.APPROACH_WITH_GAIN_DIST:
        sX = MyMath.clip(ball.dist * constants.APPROACH_X_GAIN,
                         constants.MIN_APPROACH_X_SPEED,
                         constants.MAX_APPROACH_X_SPEED)
    else:
        sX = constants.MAX_APPROACH_X_SPEED

    # Determine the speed to turn to the ball
    sTheta = MyMath.clip(ball.bearing * constants.APPROACH_SPIN_GAIN,
                         -constants.APPROACH_SPIN_SPEED,
                         constants.APPROACH_SPIN_SPEED)
    # Avoid spinning so slowly that we step in place
    if fabs(sTheta) < constants.MIN_APPROACH_SPIN_MAGNITUDE:
        sTheta = 0.0

    # Set our walk towards the ball
    if ball.on:
        player.setWalk(sX, 0, sTheta)

    return player.stay()
コード例 #35
0
ファイル: GoalieSaveStates.py プロジェクト: bbellon/nbites
def goalieSave(player):

#going to want it to get in a squat to prepare at somepoint in here

    brain = player.brain
    if player.firstFrame():
        player.isSaving = True
        player.isChasing = False
        brain.motion.stopHeadMoves()
        player.stopWalking()
        brain.tracker.trackBall()

    if helper.shouldSave(player):
        return player.goNow('goaliePickSave')

    return player.stay()
コード例 #36
0
ファイル: ChaseBallStates.py プロジェクト: Zakat/nao-man
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()
コード例 #37
0
def goaliePosition(player):
    """
    Have the robot navigate to the position reported to it from playbook
    """
    nav = player.brain.nav
    my = player.brain.my
    ball = player.brain.ball
    heading = None

    if player.firstFrame():
        nav.positionPlaybook()
        player.brain.tracker.trackBallFixedPitch()

    if goalTran.goalieIsLost(player):
        return player.goLater('spinToField')

    return player.stay()
コード例 #38
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()
コード例 #39
0
def goalieSpinToPosition(player):
    nav = player.brain.nav
    if helper.useFarPosition(player):
        player.brain.tracker.activeLoc()
    else:
        player.brain.tracker.trackBall()

    if not nav.atHeading(NogginConstants.OPP_GOAL_HEADING):
        spinDir = MyMath.getSpinDir(player.brain.my.h,
                                    NogginConstants.OPP_GOAL_HEADING)
        player.setSpeed(0, 0, spinDir*10)
        return player.stay()
    else:
        player.stopWalking()
        return player.goLater('goaliePosition')

    return player.stay()
コード例 #40
0
def goaliePosition(player):
    """
    Have the robot navigate to the position reported to it from playbook
    """
    nav = player.brain.nav
    my = player.brain.my
    ball = player.brain.ball
    heading = None

    if player.firstFrame():
        nav.positionPlaybook()
        player.brain.tracker.trackBall()

    if goalTran.goalieIsLost(player):
        return player.goLater('spinToField')

    return player.stay()
コード例 #41
0
ファイル: ChaseBallStates.py プロジェクト: thiggins/nbites
def approachDangerousBall(player):
    """adjusts position to be farther away from the ball
    if the goalie is too close to the ball while in
    the goal box"""
    if player.firstFrame():
        player.stopWalking()

    #move away from the ball so it is no longer dangerous
    if player.brain.nav.isStopped():
        if player.brain.ball.loc.relY > 0:
            player.brain.nav.walk(0, -15, 0)
        else:
            player.brain.nav.walk(0, 15, 0)

    if not goalTran.dangerousBall(player) or transitions.shouldFindBall(player):
        return player.goLater('chase')

    return player.stay()
コード例 #42
0
ファイル: ChaseBallStates.py プロジェクト: Lrosias/nbites
def approachDangerousBall(player):
    """adjusts position to be farther away from the ball
    if the goalie is too close to the ball while in
    the goal box"""
    if player.firstFrame():
        player.stopWalking()

    #move away from the ball so it is no longer dangerous
    if player.brain.nav.isStopped():
        if player.brain.ball.loc.relY > 0:
            player.brain.nav.walk(0, -15, 0)
        else:
            player.brain.nav.walk(0, 15, 0)

    if not goalTran.dangerousBall(player) or transitions.shouldFindBall(player):
        return player.goLater('chase')

    return player.stay()
コード例 #43
0
def goaliePositionBallFar(player):

    nav = player.brain.nav
    player.brain.tracker.activeLoc()

    if helper.outOfPosition(player):
        player.goLater('goalieOutOfPosition')
    #elif not nav.atHeading(NogginConstants.OPP_GOAL_HEADING):
    #    return player.goLater('goalieSpinToPosition')
    elif helper.useLeftStrafeFarSpeed(player):
        helper.strafeLeftSpeed(player)
    elif helper.useRightStrafeFarSpeed(player):
        helper.strafeRightSpeed(player)
    else:
        player.stopWalking()

    #Don't switch out if we don't see the ball
    if helper.useClosePosition(player):
        return player.goLater('goaliePositionBallClose')
    return player.stay()
コード例 #44
0
ファイル: ChaseBallStates.py プロジェクト: bbellon/nbites
def approachDangerousBall(player):
    ball = player.brain.ball
    my = player.brain.my
    if player.firstFrame():
        player.stopWalking()

    #move away from the ball so it is no longer dangerous
    if player.brain.nav.isStopped():
        if ball.relY > 0:
            player.brain.nav.walk(0, -15, 0)
        else:
            player.brain.nav.walk(0, 15, 0)

    if not goalTran.dangerousBall(player):
        return player.goLater('chase')
    if transitions.shouldScanFindBall(player):
        return player.goLater('scanFindBall')

    return player.stay()
コード例 #45
0
def holdLeftSave(player):
    if helper.shouldHoldSave(player):
        player.executeMove(SweetMoves.SAVE_LEFT_HOLD_DEBUG)
    else:
        return player.goLater('postSave')
    return player.stay()
コード例 #46
0
ファイル: GoalieSaveStates.py プロジェクト: thiggins/nbites
def saveStrafe(player):
    strafeDir = helper.strafeDirForSave(player)
    if fabs(strafeDir) > 0:
        player.setWalk(0, constants.STRAFE_SPEED * MyMath.sign(strafeDir), 0)
    else:
        player.stopWalking()
コード例 #47
0
def holdCenterSave(player):
    if helper.shouldHoldSave(player):
        pass # player.executeMove(SweetMoves.SAVE_CENTER_HOLD_DEBUG)
    else:
        return player.goLater('postSave')
    return player.stay()