本文整理汇总了Python中RoleConstants.isDefender方法的典型用法代码示例。如果您正苦于以下问题:Python RoleConstants.isDefender方法的具体用法?Python RoleConstants.isDefender怎么用?Python RoleConstants.isDefender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleConstants
的用法示例。
在下文中一共展示了RoleConstants.isDefender方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: positionAtHome
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isDefender [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 player.firstFrame():
player.brain.tracker.trackBall()
home = RobotLocation(player.homePosition.x, player.homePosition.y, player.homePosition.h)
if (player.brain.sharedBall.ball_on and player.brain.sharedBall.reliability >= 2 and
role.isDefender(player.role)):
sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y)
home.h = player.brain.loc.getRelativeBearing(sharedball)
elif (player.brain.sharedBall.ball_on and player.brain.sharedBall.reliability >= 1 and
role.isCherryPicker(player.role)):
sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y)
home.h = player.brain.loc.getRelativeBearing(sharedball)
fastWalk = role.isCherryPicker(player.role)
player.brain.nav.goTo(home, precision = nav.HOME,
speed = nav.QUICK_SPEED, avoidObstacles = True,
fast = fastWalk, pb = False)
home = RobotLocation(player.homePosition.x, player.homePosition.y, player.homePosition.h)
if (player.brain.sharedBall.ball_on and player.brain.sharedBall.reliability >= 2 and
role.isDefender(player.role)):
sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y)
home.h = player.brain.loc.getRelativeBearing(sharedball)
elif (player.brain.sharedBall.ball_on and player.brain.sharedBall.reliability >= 1 and
role.isCherryPicker(player.role)):
sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y)
home.h = player.brain.loc.getRelativeBearing(sharedball)
player.brain.nav.updateDest(home)
示例2: chaser
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isDefender [as 别名]
def chaser(player):
"""
Chasers position off to one side of the ball about a meter away if a chaser
or cherry picker is calling them off. Chasers position further away up field if
a defender is calling them off.
"""
if RoleConstants.isDefender(player.roleOfClaimer):
if player.brain.ball.y >= player.brain.loc.y:
return RobotLocation(player.brain.ball.x + 200,
player.brain.ball.y - CHASER_DISTANCE,
player.brain.ball.bearing_deg + player.brain.loc.h)
return RobotLocation(player.brain.ball.x + 200,
player.brain.ball.y + CHASER_DISTANCE,
player.brain.ball.bearing_deg + player.brain.loc.h)
else:
southEast = RobotLocation(player.brain.ball.x - CHASER_DISTANCE,
player.brain.ball.y - CHASER_DISTANCE,
player.brain.ball.bearing_deg + player.brain.loc.h)
southWest = RobotLocation(player.brain.ball.x - CHASER_DISTANCE,
player.brain.ball.y + CHASER_DISTANCE,
player.brain.ball.bearing_deg + player.brain.loc.h)
northEast = RobotLocation(player.brain.ball.x + CHASER_DISTANCE,
player.brain.ball.y - CHASER_DISTANCE,
player.brain.ball.bearing_deg + player.brain.loc.h)
northWest = RobotLocation(player.brain.ball.x + CHASER_DISTANCE,
player.brain.ball.y + CHASER_DISTANCE,
player.brain.ball.bearing_deg + player.brain.loc.h)
supportPostitions = [southEast,southWest,northEast,northWest]
positionsFilteredByInBounds = [position for position in supportPostitions if inBounds(position)]
if len(positionsFilteredByInBounds) > 0:
return min(positionsFilteredByInBounds, key=distanceToPosition(player))
# print "no in bounds position"
return southEast
示例3: calculateHomePosition
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isDefender [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
示例4: tooFarFromHome
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isDefender [as 别名]
def tooFarFromHome(player, distThreshold, angleThreshold):
"""
Returns true if LOC thinks we're more than *distance* away from our home
position
"""
if role.isDefender(player.role):
home = calculateHomePosition(player)
else:
home = player.homePosition
distanceTo = ((player.brain.loc.x - home.x)**2 + (player.brain.loc.y - home.y)**2)**.5
angleTo = fabs(player.brain.loc.h - home.h)
return distanceTo > distThreshold or angleTo > angleThreshold
示例5: positionAtHome
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isDefender [as 别名]
def positionAtHome(player):
"""
Go to the player's home position.
"""
if role.isDefender(player.role):
home = calculateHomePosition(player)
else:
home = player.homePosition
if player.firstFrame():
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)
示例6: adjustHeading
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isDefender [as 别名]
def adjustHeading(player):
if player.firstFrame():
# Spin to home heading
player.stand()
player.brain.tracker.repeatFixedPitchLookAhead()
dest = RelRobotLocation(0, 0, adjustHeading.desiredHeading - player.brain.loc.h)
player.brain.nav.goTo(dest, precision = nav.HOME,
speed = speeds.SPEED_SIX, avoidObstacles = False,
fast = True, pb = False)
# player.setWalk(0, 0, player.brain.loc.h - adjustHeading.desiredHeading)
# or math.fabs()
if fabs(player.brain.loc.h - adjustHeading.desiredHeading) < 15:
player.stand()
if role.isDefender(player.role):
return player.goNow('watchForBall')
else:
return player.goNow("panAtWayPoint")
示例7: prepareForKick
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isDefender [as 别名]
def prepareForKick(player):
if player.firstFrame():
player.decider = KickDecider.KickDecider(player.brain)
player.brain.nav.stand()
if not player.inKickOffPlay:
if player.shouldKickOff or player.brain.gameController.timeSincePlaying < 10:
print "Overriding kick decider for kickoff!"
player.shouldKickOff = False
player.kick = player.decider.kicksBeforeBallIsFree()
else:
if roleConstants.isDefender(player.role):
player.kick = player.decider.defender()
else:
player.kick = player.decider.attacker()
player.inKickingState = True
elif player.finishedPlay:
player.inKickOffPlay = False
return player.goNow('orbitBall')
示例8: prepareForKick
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isDefender [as 别名]
def prepareForKick(player):
if player.firstFrame():
player.decider = KickDecider.KickDecider(player.brain)
player.brain.nav.stand()
if not player.inKickOffPlay:
if player.shouldKickOff or player.brain.gameController.timeSincePlaying < 10:
print "Overriding kick decider for kickoff!"
player.shouldKickOff = False
player.kick = player.decider.motionKicksAsap()
else:
# if transitions.shouldChangeKickingStrategy(player):
# print "Time for some heroics!"
# player.kick = player.decider.timeForSomeHeroics()
# else:
player.kick = player.decider.obstacleAware(roleConstants.isDefender(player.role))
player.inKickingState = True
elif player.finishedPlay:
player.inKickOffPlay = False
return player.goNow("orbitBall")
示例9: shouldSpinSearchFromWatching
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isDefender [as 别名]
def shouldSpinSearchFromWatching(player):
shouldExtendTimer = player.commMode == 2 and role.isDefender(player.role)
spinTimer = 25 if shouldExtendTimer else 12
return (player.stateTime > spinTimer and
player.brain.ball.vis.frames_off > 30)
示例10: ballInTheirHalf
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isDefender [as 别名]
def ballInTheirHalf(player):
if role.isDefender(player.role):
return player.brain.sharedBall.ball_on and (player.brain.sharedBall.x > (nogginC.MIDFIELD_X + nogginC.CENTER_CIRCLE_RADIUS))
return False