当前位置: 首页>>代码示例>>Python>>正文


Python RoleConstants.isCherryPicker方法代码示例

本文整理汇总了Python中RoleConstants.isCherryPicker方法的典型用法代码示例。如果您正苦于以下问题:Python RoleConstants.isCherryPicker方法的具体用法?Python RoleConstants.isCherryPicker怎么用?Python RoleConstants.isCherryPicker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RoleConstants的用法示例。


在下文中一共展示了RoleConstants.isCherryPicker方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: positionAtHome

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isCherryPicker [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)
开发者ID:emamanto,项目名称:nbites,代码行数:37,代码来源:PlayOffBallStates.py

示例2: positionAtHome

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isCherryPicker [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)
开发者ID:joshimhoff,项目名称:nbites,代码行数:45,代码来源:PlayOffBallStates.py


注:本文中的RoleConstants.isCherryPicker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。