def __init__(self, gameState, costFn = lambda x: 1, goal=(1,1), start=None, warn=True, visualize=True):
"""
Stores the start and goal.
gameState: A GameState object (pacman.py)
costFn: A function from a search state (tuple) to a non-negative number
goal: A position in the gameState
"""
self.walls = gameState.getWalls()
self.startState = gameState.getPacmanPosition()
self.capsules = gameState.getCapsules()
# hacky
self.gameState = gameState
ghosts = gameState.getGhostPositions()
if len(ghosts) != 1:
print 'Warning: this does not look a Wumpus maze'
self.wumpus = ghosts[0]
if start != None: self.startState = start
if warn and (gameState.getNumFood() != 1):
print 'Warning: this does not look a Wumpus maze'
food = gameState.getFood()
self.goal = food.asList()[0]
self.costFn = costFn
self.visualize = visualize
# For display purposes
self._visited, self._visitedlist, self._expanded = {}, [], 0 # DO NOT CHANGE
评论列表
文章目录