本文整理汇总了Python中RoleConstants.isLeftDefender方法的典型用法代码示例。如果您正苦于以下问题:Python RoleConstants.isLeftDefender方法的具体用法?Python RoleConstants.isLeftDefender怎么用?Python RoleConstants.isLeftDefender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleConstants
的用法示例。
在下文中一共展示了RoleConstants.isLeftDefender方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calculateHomePosition
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isLeftDefender [as 别名]
def calculateHomePosition(player):
"""
Calculate home position.
"""
# We've seen the ball recently enough
if player.brain.ball.vis.frames_off < 20:
ball = player.brain.ball
bearing = ball.bearing_deg
elif player.brain.sharedBall.ball_on:
ball = player.brain.sharedBall
bearing = degrees(atan2(ball.y - player.brain.loc.y,
ball.x - player.brain.loc.x)) - player.brain.loc.h
else:
ball = None
if ball != None and not (role.isDefender(player.role) and NogginConstants.FIXED_D_HOME):
if role.isLeftDefender(player.role):
home = findDefenderHomeWithBall(player, True, ball, bearing + player.brain.loc.h)
elif role.isRightDefender(player.role):
home = findDefenderHomeWithBall(player, False, ball, bearing + player.brain.loc.h)
elif role.isStriker(player.role):
home = findStrikerHome(ball, bearing + player.brain.loc.h)
else:
home = player.homePosition
else:
if role.isLeftDefender(player.role):
home = findDefenderHomeNoBall(player, True)
elif role.isRightDefender(player.role):
home = findDefenderHomeNoBall(player, False)
else:
home = player.homePosition
return home
示例2: tooFarFromHome
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isLeftDefender [as 别名]
def tooFarFromHome(threshold, player):
"""
Returns true if LOC thinks we're more than *distance* away from our home
position
"""
if player.brain.ball.vis.frames_off < 10:
ball = player.brain.ball
elif player.brain.sharedBall.ball_on:
ball = player.brain.sharedBall
else:
ball = None
home = player.homePosition
if ball != None:
if role.isLeftDefender(player.role):
home = findDefenderHome(True, ball, player.homePosition.h)
elif role.isRightDefender(player.role):
home = findDefenderHome(False, ball, player.homePosition.h)
elif role.isStriker(player.role):
home = findStrikerHome(ball, player.homePosition.h)
else:
home = player.homePosition
distance = ((player.brain.loc.x - home.x) ** 2 + (player.brain.loc.y - home.y) ** 2) ** 0.5
return distance > threshold
示例3: branchOnRole
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isLeftDefender [as 别名]
def branchOnRole(player):
"""
Chasers are going to have a different behavior again.
We will branch on behavior based on role here
"""
# print "----------In branch on role----------"
# print "Entered Branch on Role"
# print "----- evenDefenderIsForward, lastEvenDefenderForwardVal ----"
# print player.brain.evenDefenderIsForward, lastEvenDefenderForwardVal
# global lastEvenDefenderForwardVal
# player.brain.evenDefenderIsForward = not lastEvenDefenderForwardVal
# newEvenDefenderForwardVal = True
# print("TIME SINCE PLAYING:", player.brain.gameController.timeSincePlaying)
if role.isFirstChaser(player.role):
if transitions.shouldFindSharedBall(player) and player.brain.gameController.timeSincePlaying > 75:
return player.goNow('searchFieldForSharedBall')
return player.goNow('playerFourSearchBehavior')
elif role.isStriker(player.role):
return player.goNow('playerFiveSearchBehavior')
elif role.isLeftDefender(player.role):
# print "Player Brain Left Forward 1: " + str(leftDefenderIsForward)
# if (player.brain.sharedBall.ball_on) and (player.brain.sharedBall.x < NogginConstants.MIDFIELD_X):
# print "WE ARE IN HERE"
# return player.goNow('leftDefenderBack')
if leftDefenderIsForward:
# print "Changing to False"
global leftDefenderIsForward
leftDefenderIsForward = False
# print "Player Brain Left Forward 2: " + str(leftDefenderIsForward)
return player.goNow('leftDefenderForward')
else:
# print "Changing to True"
global leftDefenderIsForward
leftDefenderIsForward = True
# print "Player Brain Left Forward 3: " + str(leftDefenderIsForward)
return player.goNow('leftDefenderBack')
else:
return player.goNow('positionAtHome')
示例4: getSupporterPosition
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isLeftDefender [as 别名]
def getSupporterPosition(player, role):
"""
Returns a position to stand at to support teammate who is chasing the ball.
Used in positionAsSupporter in PlayOffBallStates.
"""
if RoleConstants.isLeftDefender(role):
return leftDefender(player)
elif RoleConstants.isRightDefender(role):
return rightDefender(player)
elif RoleConstants.isChaser(role):
return chaser(player)
else: # cherry picker
return cherryPicker(player)
示例5: doSecondHalfSpin
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isLeftDefender [as 别名]
def doSecondHalfSpin(player):
"""
Keep spinning in the same direction.
"""
if player.firstFrame():
# print "----------Doing second half spin-------------"
player.brain.tracker.repeatFixedPitchLookAhead()
if player.brain.playerNumber == 3:
player.setWalk(0, 0, speeds.SPEED_SIX)
else:
player.setWalk(0, 0, -speeds.SPEED_SIX)
if player.stateTime > chaseConstants.SPEED_SIX_SPUN_ONCE_TIME / 2:
if role.isLeftDefender(player.role):
return player.goNow('defenderPan')
else:
return player.goNow('playOffBall')
示例6: positionAtHome
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isLeftDefender [as 别名]
def positionAtHome(player):
"""
Go to the player's home position. Defenders look in the direction of the
shared ball if it is on with reliability >= 2. Cherry pickers look in the direction
of the shared ball if it is on with reliability >= 1.
"""
if role.isFirstChaser(player.role) and transitions.shouldFindSharedBall(player):
return player.goLater('searchFieldForSharedBall')
if player.brain.ball.vis.frames_off < 10:
ball = player.brain.ball
bearing = ball.bearing_deg
elif player.brain.sharedBall.ball_on:
ball = player.brain.sharedBall
bearing = degrees(atan2(ball.y - player.brain.loc.y,
ball.x - player.brain.loc.x)) - player.brain.loc.h
else:
ball = None
home = player.homePosition
if ball != None:
if role.isLeftDefender(player.role):
home = findDefenderHome(True, ball, bearing + player.brain.loc.h)
elif role.isRightDefender(player.role):
home = findDefenderHome(False, ball, bearing + player.brain.loc.h)
elif role.isStriker(player.role):
home = findStrikerHome(ball, bearing + player.brain.loc.h)
else:
home = player.homePosition
if player.firstFrame():
if role.isCherryPicker(player.role):
player.brain.tracker.repeatBasicPan()
else:
player.brain.tracker.trackBall()
fastWalk = role.isChaser(player.role)
player.brain.nav.goTo(home, precision = nav.HOME,
speed = nav.QUICK_SPEED, avoidObstacles = True,
fast = fastWalk, pb = False)
player.brain.nav.updateDest(home)