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


Python RoleConstants.isFirstChaser方法代码示例

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


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

示例1: watchForBall

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isFirstChaser [as 别名]
def watchForBall(player):
    """
    The player is at home, waiting for the ball to be within box.
    """

    if player.firstFrame():
        # print "-----------Player at home - Watching for ball-----------"
        player.brain.tracker.trackBall()
        player.brain.nav.stand()

    # I commented this out because we were getting strange oscillations
    # between this and positonAtHome, and honestly we never go here unless
    # we are already at home... dumb...
    # if transitions.tooFarFromHome(player, 50, 20):
    #     return player.goLater('positionAtHome')

    if role.isFirstChaser(player.role):
        if player.stateTime >= tracking.INITIALIZE_HEADING_TIME + tracking.FULL_WIDE_PAN_TIME:
                return player.goNow('spinAtHome')
    elif role.isStriker(player.role):
        if player.stateTime >= tracking.INITIALIZE_HEADING_TIME + tracking.FULL_WIDE_PAN_TIME * 2:
            return player.goNow('spinAtHome')
    else:
        if player.stateTime >= tracking.INITIALIZE_HEADING_TIME + tracking.FULL_WIDE_PAN_TIME * 2:
            return player.goNow('spinAtHome')
开发者ID:northern-bites,项目名称:nbites,代码行数:27,代码来源:PlayOffBallStates.py

示例2: shouldCedeClaim

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isFirstChaser [as 别名]
def shouldCedeClaim(player):
    if not player.useClaims:
        return False

    playerWeight = weightedDistAndHeading(player.brain.ball.distance, \
                                              player.brain.loc.h, player.brain.ball.bearing_deg)
    for mate in player.brain.teamMembers:
        if (mate.playerNumber == player.brain.playerNumber):
            continue
        if not mate.claimedBall or not mate.active or mate.fallen:
            continue

        # Now we get into actual claims
        if ((player.brain.time - mate.claimTime) > claimExpiration):
            print "claim expired"
            continue # That claim has expired (Comm is probably lagging)

        mateWeight = weightedDistAndHeading(mate.ballDist, mate.h, mate.ballBearing)

        # sigmoid function so that the difference increases slowly at close distances but
        # grows quickly at mid-range to far distances and at very far distances, asymptotically
        # approaches a maximum. uses the distance of the close robot
        if player.brain.ball.distance < mate.ballDist:
            closerDistance = player.brain.ball.distance
        else:
            closerDistance = mate.ballDist
        closeWeightDifference = 25 + 150/(1 + math.e**(6.25 - .05*closerDistance))
        if (math.fabs(mateWeight - playerWeight) < closeWeightDifference):
            if roleConstants.isFirstChaser(mate.role):
                player.roleOfClaimer =  mate.role
                player.claimedBall = False
                return True
            elif player.role < mate.role and not roleConstants.isFirstChaser(player.role):
                player.roleOfClaimer =  mate.role
                player.claimedBall = False
                return True
        elif (mateWeight < playerWeight):
            player.roleOfClaimer =  mate.role
            player.claimedBall = False
            return True

    player.claimedBall = True
    return False
开发者ID:CheddarB,项目名称:nbites,代码行数:45,代码来源:ClaimTransitions.py

示例3: branchOnRole

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isFirstChaser [as 别名]
def branchOnRole(player):
    """
    Chasers are going to have a different behavior again.
    We will branch on behavior based on role here
    """

    # print "----------In branch on role----------"

    # print "Entered Branch on Role"
    # print "----- evenDefenderIsForward, lastEvenDefenderForwardVal ----"
    # print player.brain.evenDefenderIsForward, lastEvenDefenderForwardVal

    # global lastEvenDefenderForwardVal
    # player.brain.evenDefenderIsForward = not lastEvenDefenderForwardVal
    # newEvenDefenderForwardVal = True
    # print("TIME SINCE PLAYING:", player.brain.gameController.timeSincePlaying)
    if role.isFirstChaser(player.role):
        if transitions.shouldFindSharedBall(player) and player.brain.gameController.timeSincePlaying > 75:
            return player.goNow('searchFieldForSharedBall')
        return player.goNow('playerFourSearchBehavior') 
    elif role.isStriker(player.role):
        return player.goNow('playerFiveSearchBehavior')
    elif role.isLeftDefender(player.role):

        # print "Player Brain Left Forward 1: " + str(leftDefenderIsForward)

        # if (player.brain.sharedBall.ball_on) and (player.brain.sharedBall.x < NogginConstants.MIDFIELD_X):

            # print "WE ARE IN HERE"

            # return player.goNow('leftDefenderBack')
        if leftDefenderIsForward:

            # print "Changing to False"

            global leftDefenderIsForward

            leftDefenderIsForward = False

            # print "Player Brain Left Forward 2: " + str(leftDefenderIsForward)

            return player.goNow('leftDefenderForward')
        else:

            # print "Changing to True"

            global leftDefenderIsForward

            leftDefenderIsForward = True

            # print "Player Brain Left Forward 3: " + str(leftDefenderIsForward)

            return player.goNow('leftDefenderBack')
    else:
        return player.goNow('positionAtHome')
开发者ID:northern-bites,项目名称:nbites,代码行数:57,代码来源:PlayOffBallStates.py

示例4: doSecondHalfSpin

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isFirstChaser [as 别名]
def doSecondHalfSpin(player):
    """
    Keep spinning in the same direction.
    """
    if player.firstFrame():
        player.setWalk(0, 0, nav.QUICK_SPEED)
        player.brain.tracker.lookToSpinDirection(1)

    while player.stateTime < chaseConstants.SPUN_ONCE_TIME_THRESH / 2:
        return player.stay()

    if role.isFirstChaser(player.role):
        return player.goNow('searchFieldByQuad')
    return player.goNow('playOffBall')
开发者ID:itumanen,项目名称:nbites,代码行数:16,代码来源:PlayOffBallStates.py

示例5: ballNotInBufferedBox

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isFirstChaser [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.isFirstChaser(player.role)))
开发者ID:MarcusEFC,项目名称:nbites,代码行数:16,代码来源:PlayOffBallTransitions.py

示例6: getSupporterPosition

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isFirstChaser [as 别名]
def getSupporterPosition(player, r):
    """
    Returns a position to stand at to support teammate who is chasing the ball.
    Used in positionAsSupporter in PlayOffBallStates.
    """
    if role.isLeftDefender(r):
        return leftDefender(player)
    elif role.isRightDefender(r):
        return rightDefender(player)
    elif role.isFirstChaser(r):
        return chaser(player)
    elif role.isStriker(r):
        return striker(player)
    else: # cherry picker
        return cherryPicker(player)
开发者ID:northern-bites,项目名称:nbites,代码行数:17,代码来源:SupporterConstants.py

示例7: doPan

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isFirstChaser [as 别名]
def doPan(player):
    """
    Wide pan for 5 seconds.
    """

    if player.firstFrame():
        # print "------------Doing Pan-------------"

        player.stand()
        player.brain.tracker.trackBall()

    if player.stateTime >= tracking.INITIALIZE_HEADING_TIME + tracking.FULL_WIDE_PAN_TIME:
        if role.isFirstChaser(player.role):
            return player.goNow('playerFourSearchBehavior')
        elif role.isStriker(player.role):
            return player.goNow('playerFiveSearchBehavior')
        else:
            return player.goNow('doSecondHalfSpin')
开发者ID:northern-bites,项目名称:nbites,代码行数:20,代码来源:PlayOffBallStates.py

示例8: positionAtHome

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isFirstChaser [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

示例9: panAtWayPoint

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isFirstChaser [as 别名]
def panAtWayPoint(player):

    if player.firstFrame():
        player.stand()
        player.brain.tracker.trackBall()

    # if role.isFirstChaser(player.role) and not playerFourSearchBehavior.pointIndex % len(playerFourPoints) == 0:
    #     if player.stateTime >= FULL_WIDE_PAN_TIME:
    #         return player.goNow("playerFourSearchBehavior")

    # elif player.stateTime >= FULL_WIDE_PAN_TIME * 2:
    #     return player.goNow("spinAtHome")

    if role.isFirstChaser(player.role) and not playerFourSearchBehavior.pointIndex % len(playerFourPoints) == 0:
        if player.stateTime >= tracking.INITIALIZE_HEADING_TIME + tracking.FULL_WIDE_PAN_TIME:
            return player.goNow("playerFourSearchBehavior")
    elif role.isStriker(player.role):
        if player.stateTime >= tracking.INITIALIZE_HEADING_TIME + tracking.FULL_WIDE_PAN_TIME * 2:
            return player.goNow('spinAtHome')
    else:
        if player.stateTime >= tracking.INITIALIZE_HEADING_TIME + tracking.FULL_WIDE_PAN_TIME:
            return player.goNow('spinAtHome')
开发者ID:northern-bites,项目名称:nbites,代码行数:24,代码来源:PlayOffBallStates.py

示例10: shouldFindSharedBall

# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import isFirstChaser [as 别名]
def shouldFindSharedBall(player):
    return (role.isFirstChaser(player.role) and
            player.brain.ball.vis.frames_off > 10 and
            player.brain.sharedBall.ball_on and
            player.brain.sharedBall.reliability >= 1)
开发者ID:MarcusEFC,项目名称:nbites,代码行数:7,代码来源:PlayOffBallTransitions.py


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