示例#1
0
    def newGame(self,
                layout,
                pacmanType,
                ghostType,
                display,
                agentOpts,
                quiet=False,
                catchExceptions=False):
        # TODO done
        # agents = [pacmanAgent] + ghostAgents[:layout.getNumGhosts()]
        agents = []
        # agents = pacmanAgent[:layout.numPacman] + \
        #     ghostAgents[:layout.getNumGhosts()]
        initState = GameState()
        initState.initialize(layout)

        for index, agentState in enumerate(initState.data.agentStates):
            if agentState.isPacman:
                agents.append(pacmanType(agentOpts, index, agentState))
            else:
                agents.append(ghostType(agentOpts, index, agentState))

        game = Game(agents, display, self, catchExceptions=catchExceptions)
        game.state = initState
        initState.game = game

        self.initialState = initState.deepCopy()

        self.quiet = quiet
        return game