Exemplo n.º 1
0
def replayGame(layout, actions, display):
    import pacmanAgents
    import ghostAgents
    rules = ClassicGameRules()
    agents = [pacmanAgents.GreedyAgent()] + [ghostAgents.RandomGhost(i + 1)
                                             for i in range(layout.getNumGhosts())]
    game = rules.newGame(layout, agents[0], agents[1:], display)
    state = game.state
    display.initialize(state.data)

    for action in actions:
            # Execute the action
        state = state.generateSuccessor(*action)
        # Change the display
        display.update(state.data)
        # Allow for game specific conditions (winning, losing, etc.)
        rules.process(state, game)

    display.finish()
Exemplo n.º 2
0
def replayGame(layout, actions, display):
    import submission, ghostAgents
    rules = ClassicGameRules()
    # If replaying, change the agent from ExpectimaxAgent to whatever agent with which you want to play
    agents = [submission.ExpectimaxAgent()] + [
        ghostAgents.RandomGhost(i + 1) for i in range(layout.getNumGhosts())
    ]
    game = rules.newGame(layout, agents[0], agents[1:], display)
    state = game.state
    display.initialize(state.data)

    for action in actions:
        # Execute the action
        state = state.generateSuccessor(*action)
        # Change the display
        display.update(state.data)
        # Allow for game specific conditions (winning, losing, etc.)
        rules.process(state, game)

    display.finish()
Exemplo n.º 3
0
def replayGame(layout, actions, display):
    import submission, ghostAgents
    rules = ClassicGameRules()

    agents = [submission.ExpectimaxAgent()] + [
        ghostAgents.RandomGhost(i + 1) for i in range(layout.getNumGhosts())
    ]
    game = rules.newGame(layout, agents[0], agents[1:], display)
    state = game.state
    display.initialize(state.data)

    for action in actions:

        state = state.generateSuccessor(*action)

        display.update(state.data)

        rules.process(state, game)

    display.finish()
Exemplo n.º 4
0
def replayGame( layout, actions, display ):
    import pacmanAgents, ghostAgents
    import csv 
    
    global GSTATE, PSA

    rules = ClassicGameRules()
    agents = [pacmanAgents.GreedyAgent()] + [ghostAgents.RandomGhost(i+1) for i in range(layout.getNumGhosts())]
    game = rules.newGame( layout, agents[0], agents[1:], display )
    state = game.state
    display.initialize(state.data)

    c = 0
    prevState = state

    for action in actions:

        # Execute the action
        state = state.generateSuccessor( *action )
        # Change the display
        display.update( state.data )

        # Allow for game specific conditions (winning, losing, etc.)
        rules.process(state, game)

        #after pacman moves, pause 
        if c%2 == 0 :
            PSA[c/2] = (prevState.__str__(),action[1])
            #print(prevState.__str__())
            time.sleep(1)
            #record state we respond to
            prevState = state
            GSTATE += 1

            #if flask, get here

        c+=1

    display.finish()