logicAgents.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:AIclass 作者: mttk 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号