本文整理汇总了Python中ChaseBallTransitions.shouldNotGoInBox方法的典型用法代码示例。如果您正苦于以下问题:Python ChaseBallTransitions.shouldNotGoInBox方法的具体用法?Python ChaseBallTransitions.shouldNotGoInBox怎么用?Python ChaseBallTransitions.shouldNotGoInBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChaseBallTransitions
的用法示例。
在下文中一共展示了ChaseBallTransitions.shouldNotGoInBox方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: approachBallWalk
# 需要导入模块: import ChaseBallTransitions [as 别名]
# 或者: from ChaseBallTransitions import shouldNotGoInBox [as 别名]
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()
示例2: approachBallWithLoc
# 需要导入模块: import ChaseBallTransitions [as 别名]
# 或者: from ChaseBallTransitions import shouldNotGoInBox [as 别名]
def approachBallWithLoc(player):
if player.firstFrame():
player.brain.CoA.setRobotGait(player.brain.motion)
player.hasAlignedOnce = False
nav = player.brain.nav
my = player.brain.my
if player.brain.playbook.role == pbc.GOALIE:
if transitions.shouldKick(player):
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goNow('waitBeforeKick')
elif transitions.shouldPositionForKickFromApproachLoc(player):
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goLater('positionForKick')
elif my.locScoreFramesBad > constants.APPROACH_NO_LOC_THRESH:
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goLater('approachBall')
elif not player.brain.tracker.activeLocOn and \
transitions.shouldScanFindBall(player):
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goLater('scanFindBall')
else:
if transitions.shouldKick(player):
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goNow('waitBeforeKick')
elif transitions.shouldPositionForKickFromApproachLoc(player):
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goLater('positionForKick')
elif transitions.shouldNotGoInBox(player):
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goLater('ballInMyBox')
elif transitions.shouldChaseAroundBox(player):
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goLater('chaseAroundBox')
elif transitions.shouldAvoidObstacleDuringApproachBall(player):
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goLater('avoidObstacle')
elif my.locScoreFramesBad > constants.APPROACH_NO_LOC_THRESH:
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goLater('approachBall')
elif not player.brain.tracker.activeLocOn and \
transitions.shouldScanFindBall(player):
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goLater('scanFindBall')
elif player.brain.tracker.activeLocOn and \
transitions.shouldScanFindBallActiveLoc(player):
player.brain.CoA.setRobotGait(player.brain.motion)
return player.goLater('scanFindBall')
#if player.brain.ball.locDist > constants.APPROACH_ACTIVE_LOC_DIST:
if transitions.shouldActiveLoc(player):
player.brain.tracker.activeLoc()
else :
player.brain.tracker.trackBall()
dest = player.getApproachPosition()
useOmni = MyMath.dist(my.x, my.y, dest[0], dest[1]) <= \
constants.APPROACH_OMNI_DIST
changedOmni = False
if useOmni != nav.movingOmni:
player.changeOmniGoToCounter += 1
else :
player.changeOmniGoToCounter = 0
if player.changeOmniGoToCounter > PositionConstants.CHANGE_OMNI_THRESH:
changedOmni = True
if player.firstFrame() or \
nav.destX != dest[0] or \
nav.destY != dest[1] or \
nav.destH != dest[2] or \
changedOmni:
if not useOmni:
player.brain.CoA.setRobotGait(player.brain.motion)
nav.goTo(dest)
else:
player.brain.CoA.setRobotSlowGait(player.brain.motion)
nav.omniGoTo(dest)
return player.stay()