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


Python RoleConstants.canRoleSwitchTo方法代码示例

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


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

示例1: checkForConsistency

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import canRoleSwitchTo [as 别名]
def checkForConsistency(player):
    """
    Checks to see if anyone else has the same role as us. If they also have
    a lower playerNumber then we change. Otherwise we assume that they will
    fix the issue. Very similar in structure to determineRole in penalty states.
    """
    if not player.roleSwitching:
        return

    openSpaces = [True, True, True, True]
    conflict = False
    position = 0

    for mate in player.brain.teamMembers:
        if mate.playerNumber == player.brain.playerNumber:
            continue
        openSpaces[mate.role - 2] = False
        if mate.role == player.role and mate.playerNumber > player.brain.playerNumber and mate.frameSinceActive < 30:
            conflict = True

    if not conflict:
        return  # The expected outcome

    for i in range(3):
        if openSpaces[i] and constants.canRoleSwitchTo(i + 2):
            constants.setRoleConstants(player, i + 2)
            return
        elif openSpaces[i]:
            position = i + 2

    if position == 0:
        print "We have conflicting role AND there are no more open roles..."

    constants.setRoleConstants(player, position)
    return
开发者ID:nbitesGuest,项目名称:nbites,代码行数:37,代码来源:RoleSwitchingTransitions.py

示例2: determineRole

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import canRoleSwitchTo [as 别名]
def determineRole(player):
    if not player.roleSwitching:
        return player.goLater(player.gameState)

    openSpaces = [True, True, True, True]
    for mate in player.brain.teamMembers:
        if mate.playerNumber == player.brain.playerNumber:
            continue
        if not roleConstants.isGoalie(mate.role) \
                and mate.frameSinceActive < 30:
            openSpaces[mate.role - 2] = False

    position = 0

    for i in range(4):
        if openSpaces[i] and roleConstants.canRoleSwitchTo(i+2):
            roleConstants.setRoleConstants(player, i+2)
            return player.goLater(player.gameState)
        elif openSpaces[i]:
            position = i+2

    if position == 0:
        print "Came out of penalty and found no open spaces!!!"

    roleConstants.setRoleConstants(player, i+2)
    return player.goLater(player.gameState)
开发者ID:dnav6987,项目名称:nbites,代码行数:28,代码来源:PenaltyStates.py

示例3: chaserIsOut

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import canRoleSwitchTo [as 别名]
def chaserIsOut(player):
    """
    There is a chaser spot ready to be filled.
    """
    if not player.roleSwitching or player.brain.gameController.penalized:
        return False

    if not player.gameState == "gamePlaying":
        return False

    checkForConsistency(player)

    if constants.canRoleSwitchTo(player.role):
        return False

    openPositions = ()
    positions = [False, False, False, False]
    for mate in player.brain.teamMembers:
        if mate.role <= 1:
            continue
        if mate.frameSinceActive < 30:
            positions[mate.role - 2] = True
        if mate.playerNumber == player.brain.playerNumber:
            continue
        if constants.canRoleSwitchTo(mate.role) and mate.frameSinceActive > 30:
            openPositions += (mate.role,)

        if (
            constants.willRoleSwitch(mate.role)
            and mate.playerNumber > player.brain.playerNumber
            and (mate.frameSinceActive < 30 or not mate.active)
        ):
            return False  # Active, higher numbered player takes precedence

    for pos in openPositions:
        if not positions[pos - 2]:
            player.openChaser = pos
            print "Switching to role: ", pos
            return True

    return False
开发者ID:nbitesGuest,项目名称:nbites,代码行数:43,代码来源:RoleSwitchingTransitions.py


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