Module pacai.agents.gowest

Expand source code
from pacai.agents.base import BaseAgent
from pacai.core.directions import Directions

class GoWestAgent(BaseAgent):
    """
    An agent that goes West until it can't.
    """

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

    def getAction(self, state):
        """
        The agent receives a GameState (defined in pacman.py).
        """

        if (Directions.WEST in state.getLegalPacmanActions()):
            return Directions.WEST
        else:
            return Directions.STOP

Classes

class GoWestAgent (index, **kwargs)

An agent that goes West until it can't.

Expand source code
class GoWestAgent(BaseAgent):
    """
    An agent that goes West until it can't.
    """

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

    def getAction(self, state):
        """
        The agent receives a GameState (defined in pacman.py).
        """

        if (Directions.WEST in state.getLegalPacmanActions()):
            return Directions.WEST
        else:
            return Directions.STOP

Ancestors

Static methods

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

Inherited from: BaseAgent.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 final(self, state)

Inherited from: BaseAgent.final

Inform the agent about the result of a game.

def getAction(self, state)

The agent receives a GameState (defined in pacman.py).

Expand source code
def getAction(self, state):
    """
    The agent receives a GameState (defined in pacman.py).
    """

    if (Directions.WEST in state.getLegalPacmanActions()):
        return Directions.WEST
    else:
        return Directions.STOP
def observationFunction(self, state)

Inherited from: BaseAgent.observationFunction

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

def registerInitialState(self, state)

Inherited from: BaseAgent.registerInitialState

Inspect the starting state.