实验报告

master
huangjielun 3 years ago
parent e74b67de06
commit bb551fb0f1

@ -171,38 +171,7 @@ class MinimaxAgent(MultiAgentSearchAgent):
Returns whether or not the game state is a losing state
"""
"*** YOUR CODE HERE ***"
'''
GhostIndex = [i for i in range(1, gameState.getNumAgents())]
def gameOver(state, d):
return state.isWin() or state.isLose() or d == self.depth
def min_value(state, d, ghost): # minimizer
if gameOver(state, d):
return self.evaluationFunction(state)
Beta = 10000000000000000
for action in state.getLegalActions(ghost):
if ghost == GhostIndex[-1]:
Beta = min(Beta, max_value(state.generateSuccessor(ghost, action), d + 1))
else:
Beta = min(Beta, min_value(state.generateSuccessor(ghost, action), d, ghost + 1))
return Beta
def max_value(state, d): # maximizer
if gameOver(state, d):
return self.evaluationFunction(state)
Alpha = -10000000000000000
for action in state.getLegalActions(0):
if action == 'Stop':
continue
Alpha = max(Alpha, min_value(state.generateSuccessor(0, action), d, 1))
return Alpha
res = [(action, min_value(gameState.generateSuccessor(0, action), 0, 1)) for action in
gameState.getLegalActions(0)]
res.sort(key=lambda k: k[1])
return res[-1][0]
util.raiseNotDefined()
'''
def gameOver(gameState):
return gameState.isWin() or gameState.isLose()
#Be different with me

Binary file not shown.
Loading…
Cancel
Save