def generateSuccessor(self, action, agentIndex):
"""
Returns the successor state after the specified pursuer takes action
"""
# Check that successors exist
if self.isWin() or self.isLose():
# time.sleep(2)
raise Exception('Game over')
# Copy current state
state = GameState(self)
# Let agent's logic deal with its action's effects on the board
if agentIndex == 0: # Pacman is moving
# state.data._eaten = [False for i in range(state.getNumAgents())]
TargetRules.applyAction( state, action )
else: # A ghost is moving
PursuerRules.applyAction( state, action, agentIndex )
# Book keeping
#state.data._agentMoved = agentIndex
state.data.score += state.data.scoreChange
GameState.explored.add(self)
GameState.explored.add(state)
return state
评论列表
文章目录