本文整理汇总了Python中RoleConstants.isChaser方法的典型用法代码示例。如果您正苦于以下问题:Python RoleConstants.isChaser方法的具体用法?Python RoleConstants.isChaser怎么用?Python RoleConstants.isChaser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleConstants
的用法示例。
在下文中一共展示了RoleConstants.isChaser方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: positionAsSupporter
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [as 别名]
def positionAsSupporter(player):
if (role.isChaser(player.role) and role.isChaser(player.roleOfClaimer) and
player.brain.ball.distance > hypot(CHASER_DISTANCE, CHASER_DISTANCE)):
fast = True
else:
fast = False
positionAsSupporter.position = getSupporterPosition(player, player.role)
# TODO don't call goTo every frame
player.brain.nav.goTo(positionAsSupporter.position, precision = nav.GENERAL_AREA,
speed = nav.QUICK_SPEED, avoidObstacles = True,
fast = False, pb = False)
示例2: positionAsSupporter
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [as 别名]
def positionAsSupporter(player):
if (role.isChaser(player.role) and role.isChaser(player.roleOfClaimer) and
player.brain.ball.distance > hypot(CHASER_DISTANCE, CHASER_DISTANCE)):
fast = True
else:
fast = False
positionAsSupporter.position = getSupporterPosition(player, player.role)
if player.firstFrame():
player.brain.nav.goTo(positionAsSupporter.position, precision = nav.GENERAL_AREA,
speed = nav.QUICK_SPEED, avoidObstacles = True,
fast = False, pb = False)
player.brain.nav.updateDest(positionAsSupporter.position, fast=fast)
示例3: branchOnRole
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [as 别名]
def branchOnRole(player):
"""
Chasers have different behavior than defenders, so we branch on
role here.
"""
if role.isChaser(player.role):
if transitions.shouldFindSharedBall(player):
return player.goNow('searchFieldForSharedBall')
return player.goNow('searchFieldByQuad')
return player.goNow('positionAtHome')
示例4: branchOnRole
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [as 别名]
def branchOnRole(player):
"""
Chasers are going to have a different behavior again.
We will branch on behavior based on role here
"""
# print("TIME SINCE PLAYING:", player.brain.gameController.timeSincePlaying)
if role.isChaser(player.role):
if transitions.shouldFindSharedBall(player) and player.brain.gameController.timeSincePlaying > 75:
return player.goNow('searchFieldForSharedBall')
return player.goNow('searchFieldByQuad')
return player.goNow('positionAtHome')
示例5: ballInBox
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [as 别名]
def ballInBox(player):
"""
A transition which returns true if the ball is in the player's box
"""
ball = player.brain.ball
if ball.vis.frames_on > chaseConstants.BALL_ON_THRESH:
if role.isChaser(player.role):
return True
return (ball.x > player.box[0][0] and ball.y > player.box[0][1] and
ball.x < player.box[0][0] + player.box[1] and
ball.y < player.box[0][1] + player.box[2])
示例6: getSupporterPosition
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [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)
示例7: ballNotInBufferedBox
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [as 别名]
def ballNotInBufferedBox(player):
"""
A transition which allows a stretching of a box so that the box isn't
so ridged. Intended use is for in approachBall, ensuring that we don't loop
between approachBall and positionAtHome if the ball is close to the edge of the box.
"""
ball = player.brain.ball
buf = role.boxBuffer
inBox = (ball.x > player.box[0][0] - buf and ball.y > player.box[0][1] - buf and \
ball.x < player.box[0][0] + player.box[1] + buf and \
ball.y < player.box[0][1] + player.box[2] + buf)
return (ball.vis.frames_off > chaseConstants.BALL_OFF_THRESH or
(not inBox and not role.isChaser(player.role)))
示例8: positionAtHome
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [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)
示例9: positionAsSupporter
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [as 别名]
def positionAsSupporter(player):
positionAsSupporter.position = getSupporterPosition(player, player.role)
if player.firstFrame():
player.brain.tracker.trackBall()
fastWalk = role.isChaser(player.role)
player.brain.nav.goTo(positionAsSupporter.position, precision = nav.GENERAL_AREA,
speed = nav.QUICK_SPEED, avoidObstacles = True,
fast = fastWalk, pb = False)
if positionAsSupporter.position.distTo(player.brain.loc) > 20:
player.brain.nav.goTo(positionAsSupporter.position, precision = nav.GENERAL_AREA,
speed = nav.QUICK_SPEED, avoidObstacles = True,
fast = fastWalk, pb = False)
player.brain.nav.updateDest(positionAsSupporter.position, fast = fastWalk)
示例10: positionAtHome
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [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)
示例11: positionAtHome
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [as 别名]
def positionAtHome(player):
"""
Go to the player's home position.
"""
home = player.homePosition
if player.firstFrame():
# print "-----------Positioning at home-------------"
player.brain.tracker.trackBall()
fastWalk = role.isChaser(player.role)
player.brain.nav.goTo(home, precision = nav.HOME,
speed = speeds.SPEED_EIGHT, avoidObstacles = True,
fast = fastWalk, pb = False)
player.brain.nav.updateDest(home)
示例12: shouldNotBeSupporter
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isChaser [as 别名]
def shouldNotBeSupporter(player):
if role.isChaser(player.role):
return shared.ballOffForNFrames(120)
return not shouldBeSupporter(player)