Module pacai.agents.capture.dummy

Classes

class DummyAgent (index, **kwargs)

A Dummy agent to serve as an example of the necessary agent structure. You should look at pacai.core.baselineTeam for more details about how to create an agent.

Expand source code
class DummyAgent(CaptureAgent):
    """
    A Dummy agent to serve as an example of the necessary agent structure.
    You should look at `pacai.core.baselineTeam` for more details about how to create an agent.
    """

    def __init__(self, index, **kwargs):
        super().__init__(index, **kwargs)

    def registerInitialState(self, gameState):
        """
        This method handles the initial setup of the agent and populates useful fields,
        such as the team the agent is on and the `pacai.core.distanceCalculator.Distancer`.

        IMPORTANT: If this method runs for more than 15 seconds, your agent will time out.
        """

        super().registerInitialState(gameState)

        # Your initialization code goes here, if you need any.

    def chooseAction(self, gameState):
        """
        Randomly pick an action.
        """

        actions = gameState.getLegalActions(self.index)
        return random.choice(actions)

Ancestors

Static methods

def loadAgent(name, index, args={})

Inherited from: CaptureAgent.loadAgent

Load an agent with the given class name. The name can be fully qualified or just the bare class name. If the bare name is given, the class should …

Methods

def chooseAction(self, gameState)

Randomly pick an action.

def final(self, gameState)

Inherited from: CaptureAgent.final

Inform the agent about the result of a game.

def getAction(self, gameState)

Inherited from: CaptureAgent.getAction

Calls CaptureAgent.chooseAction on a grid position, but continues on partial positions. If you subclass CaptureAgent, you shouldn't need to …

def getCurrentObservation(self)

Inherited from: CaptureAgent.getCurrentObservation

Returns the GameState object corresponding this agent's current observation (the observed state of the game - this may not include all of your …

def getFood(self, gameState)

Inherited from: CaptureAgent.getFood

Returns the food you're meant to eat. This is in the form of a Grid where m[x][y] = True if there is food you can eat (based on …

def getFoodYouAreDefending(self, gameState)

Inherited from: CaptureAgent.getFoodYouAreDefending

Returns the food you're meant to protect (i.e., that your opponent is supposed to eat). This is in the form of a Grid where `m[x][y] …

def getMazeDistance(self, pos1, pos2)

Inherited from: CaptureAgent.getMazeDistance

Returns the distance between two points using the builtin distancer.

def getOpponents(self, gameState)

Inherited from: CaptureAgent.getOpponents

Returns agent indices of your opponents. This is the list of the numbers of the agents (e.g., red might be 1, 3, 5)

def getPreviousObservation(self)

Inherited from: CaptureAgent.getPreviousObservation

Returns the AbstractGameState object corresponding to the last state this agent saw. That is the observed state of the game …

def getScore(self, gameState)

Inherited from: CaptureAgent.getScore

Returns how much you are beating the other team by in the form of a number that is the difference between your score and the opponents score. This …

def getTeam(self, gameState)

Inherited from: CaptureAgent.getTeam

Returns agent indices of your team. This is the list of the numbers of the agents (e.g., red might be the list of 1,3,5)

def observationFunction(self, state)

Inherited from: CaptureAgent.observationFunction

Make an observation on the state of the game. Called once for each round of the game.

def registerInitialState(self, gameState)

This method handles the initial setup of the agent and populates useful fields, such as the team the agent is on and the Distancer.

IMPORTANT: If this method runs for more than 15 seconds, your agent will time out.

def registerTeam(self, agentsOnTeam)

Inherited from: CaptureAgent.registerTeam

Fills the self.agentsOnTeam field with a list of the indices of the agents on your team.