Пример #1
0
 def getLegalActions(state):
     """
     Returns a list of possible actions.
     """
     return Actions.getPossibleActions(
         state.getPacmanState().configuration, state.data.layout.walls
     )
Пример #2
0
 def getLegalActions(state, agentIndex):
     """
 Returns a list of legal actions (which are both possible & allowed)
 """
     agentState = state.getAgentState(agentIndex)
     conf = agentState.configuration
     possibleActions = Actions.getPossibleActions(conf,
                                                  state.data.layout.walls)
     if AgentRules.canFreeze(agentState):
         possibleActions.append('FREEZE')
     return AgentRules.filterForAllowedActions(agentState, possibleActions)
Пример #3
0
 def getLegalActions(state, ghostIndex):
     """
     Ghosts cannot stop, and cannot turn around unless they
     reach a dead end, but can turn 90 degrees at intersections.
     """
     conf = state.getGhostState(ghostIndex).configuration
     possibleActions = Actions.getPossibleActions(conf, state.data.layout.walls)
     reverse = Actions.reverseDirection(conf.direction)
     if Directions.STOP in possibleActions:
         possibleActions.remove(Directions.STOP)
     if reverse in possibleActions and len(possibleActions) > 1:
         possibleActions.remove(reverse)
     return possibleActions