pacai.agents.cheating

 1import pacai.core.action
 2import pacai.core.agent
 3import pacai.core.gamestate
 4import pacai.pacman.board
 5
 6class CheatingAgent(pacai.core.agent.Agent):
 7    """
 8    This agent cheats!
 9    On its turn, this agent will try to modify the game state to declare itself the winner.
10    Agent isolation should prevent this agent from cheating.
11    """
12
13    def get_action(self, state: pacai.core.gamestate.GameState) -> pacai.core.action.Action:
14        # Get a bunch of points.
15        state.score = 1000
16
17        # Eat all the food, thereby winning the game.
18        for food_position in state.board.get_marker_positions(pacai.pacman.board.MARKER_PELLET):
19            state.board.remove_marker(pacai.pacman.board.MARKER_PELLET, food_position)
20
21        # End the game.
22        state.game_over = True
23
24        return pacai.core.action.STOP
class CheatingAgent(pacai.core.agent.Agent):
 7class CheatingAgent(pacai.core.agent.Agent):
 8    """
 9    This agent cheats!
10    On its turn, this agent will try to modify the game state to declare itself the winner.
11    Agent isolation should prevent this agent from cheating.
12    """
13
14    def get_action(self, state: pacai.core.gamestate.GameState) -> pacai.core.action.Action:
15        # Get a bunch of points.
16        state.score = 1000
17
18        # Eat all the food, thereby winning the game.
19        for food_position in state.board.get_marker_positions(pacai.pacman.board.MARKER_PELLET):
20            state.board.remove_marker(pacai.pacman.board.MARKER_PELLET, food_position)
21
22        # End the game.
23        state.game_over = True
24
25        return pacai.core.action.STOP

This agent cheats! On its turn, this agent will try to modify the game state to declare itself the winner. Agent isolation should prevent this agent from cheating.

def get_action(self, state: pacai.core.gamestate.GameState) -> pacai.core.action.Action:
14    def get_action(self, state: pacai.core.gamestate.GameState) -> pacai.core.action.Action:
15        # Get a bunch of points.
16        state.score = 1000
17
18        # Eat all the food, thereby winning the game.
19        for food_position in state.board.get_marker_positions(pacai.pacman.board.MARKER_PELLET):
20            state.board.remove_marker(pacai.pacman.board.MARKER_PELLET, food_position)
21
22        # End the game.
23        state.game_over = True
24
25        return pacai.core.action.STOP

Get an action for this agent given the current state of the game. This is simplified version of get_action_full(), see that method for full details.