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
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