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


Python RoleConstants.isDefender方法代码示例

本文整理汇总了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)
开发者ID:emamanto,项目名称:nbites,代码行数:37,代码来源:PlayOffBallStates.py

示例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
开发者ID:CheddarB,项目名称:nbites,代码行数:37,代码来源:SupporterConstants.py

示例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
开发者ID:northern-bites,项目名称:nbites,代码行数:35,代码来源:SupporterConstants.py

示例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
开发者ID:MarcusEFC,项目名称:nbites,代码行数:16,代码来源:PlayOffBallTransitions.py

示例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)
开发者ID:itumanen,项目名称:nbites,代码行数:19,代码来源:PlayOffBallStates.py

示例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")
开发者ID:northern-bites,项目名称:nbites,代码行数:22,代码来源:PlayOffBallStates.py

示例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')
开发者ID:bill-silver,项目名称:nbites,代码行数:23,代码来源:ChaseBallStates.py

示例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")
开发者ID:emamanto,项目名称:nbites,代码行数:24,代码来源:ChaseBallStates.py

示例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)
开发者ID:MarcusEFC,项目名称:nbites,代码行数:7,代码来源:PlayOffBallTransitions.py

示例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
开发者ID:northern-bites,项目名称:nbites,代码行数:6,代码来源:PlayOffBallTransitions.py


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