python类nearestPoint()的实例源码

pacman.py 文件源码 项目:AIclass 作者: mttk 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def decrementTimer( ghostState):
        timer = ghostState.scaredTimer
        if timer == 1:
            ghostState.configuration.pos = nearestPoint( ghostState.configuration.pos )
        ghostState.scaredTimer = max( 0, timer - 1 )
pacman.py 文件源码 项目:AIclass 作者: mttk 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def decrementTimer( ghostState):
        timer = ghostState.scaredTimer
        if timer == 1:
            ghostState.configuration.pos = nearestPoint( ghostState.configuration.pos )
        ghostState.scaredTimer = max( 0, timer - 1 )
pacman.py 文件源码 项目:AIclass 作者: mttk 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def decrementTimer( ghostState):
        timer = ghostState.scaredTimer
        if timer == 1:
            ghostState.configuration.pos = nearestPoint( ghostState.configuration.pos )
        ghostState.scaredTimer = max( 0, timer - 1 )
pacman.py 文件源码 项目:AIclass 作者: mttk 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def decrementTimer( ghostState):
        timer = ghostState.scaredTimer
        if timer == 1:
            ghostState.configuration.pos = nearestPoint( ghostState.configuration.pos )
        ghostState.scaredTimer = max( 0, timer - 1 )
pacman.py 文件源码 项目:Pac-Man-Search 作者: xuefengDevelop 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def decrementTimer( ghostState):
        timer = ghostState.scaredTimer
        if timer == 1:
            ghostState.configuration.pos = nearestPoint( ghostState.configuration.pos )
        ghostState.scaredTimer = max( 0, timer - 1 )
pacman.py 文件源码 项目:Pacman-AI 作者: adamtache 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def decrementTimer( ghostState):
    timer = ghostState.scaredTimer
    if timer == 1:
      ghostState.configuration.pos = nearestPoint( ghostState.configuration.pos )
    ghostState.scaredTimer = max( 0, timer - 1 )
pacman.py 文件源码 项目:Pacman-AI 作者: adamtache 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def decrementTimer( ghostState):
    timer = ghostState.scaredTimer
    if timer == 1:
      ghostState.configuration.pos = nearestPoint( ghostState.configuration.pos )
    ghostState.scaredTimer = max( 0, timer - 1 )
capture.py 文件源码 项目:AI-Pacman 作者: AUTBS 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def applyAction( state, action, agentIndex ):
    """
    Edits the state to reflect the results of the action.
    """
    legal = AgentRules.getLegalActions( state, agentIndex )
    if action not in legal:
      raise Exception("Illegal action " + str(action))

    # Update Configuration
    agentState = state.data.agentStates[agentIndex]
    speed = 1
    # if agentState.isPacman: speed = 0.5
    vector = Actions.directionToVector( action, speed )
    oldConfig = agentState.configuration
    agentState.configuration = oldConfig.generateSuccessor( vector )

    # Eat
    next = agentState.configuration.getPosition()
    nearest = nearestPoint( next )

    if next == nearest:
      isRed = state.isOnRedTeam(agentIndex)
      # Change agent type
      agentState.isPacman = [isRed, state.isRed(agentState.configuration)].count(True) == 1
      # if he's no longer pacman, he's on his own side, so reset the num carrying timer
      #agentState.numCarrying *= int(agentState.isPacman)
      if agentState.numCarrying > 0 and not agentState.isPacman:
        score = agentState.numCarrying if isRed else -1*agentState.numCarrying
        state.data.scoreChange += score

        agentState.numReturned += agentState.numCarrying
        agentState.numCarrying = 0

        redCount = 0
        blueCount = 0
        for index in range(state.getNumAgents()):
          agentState = state.data.agentStates[index]
          if index in state.getRedTeamIndices():
            redCount += agentState.numReturned
          else:
            blueCount += agentState.numReturned
        if redCount >= (TOTAL_FOOD/2) - MIN_FOOD or blueCount >= (TOTAL_FOOD/2) - MIN_FOOD:
          state.data._win = True


    if agentState.isPacman and manhattanDistance( nearest, next ) <= 0.9 :
      AgentRules.consume( nearest, state, state.isOnRedTeam(agentIndex) )


问题


面经


文章

微信
公众号

扫码关注公众号