Module pacai.agents.timeout

Expand source code
import time

from pacai.agents.random import RandomAgent

DEFAULT_TIMEOUT_SEC = 2

class TimeoutAgent(RandomAgent):
    """
    A random agent that takes too much time.
    Taking too much time results in penalties and random moves.
    """

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

        self._timeout = timeout

    def getAction(self, state):
        time.sleep(self._timeout)

        return super().getAction(state)

Classes

class TimeoutAgent (index, timeout=2, **kwargs)

A random agent that takes too much time. Taking too much time results in penalties and random moves.

Expand source code
class TimeoutAgent(RandomAgent):
    """
    A random agent that takes too much time.
    Taking too much time results in penalties and random moves.
    """

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

        self._timeout = timeout

    def getAction(self, state):
        time.sleep(self._timeout)

        return super().getAction(state)

Ancestors

Static methods

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

Inherited from: RandomAgent.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: RandomAgent.final

Inform the agent about the result of a game.

def getAction(self, state)

Inherited from: RandomAgent.getAction

The BaseAgent will receive an AbstractGameState, and must return an action from Directions.

Expand source code
def getAction(self, state):
    time.sleep(self._timeout)

    return super().getAction(state)
def observationFunction(self, state)

Inherited from: RandomAgent.observationFunction

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

def registerInitialState(self, state)

Inherited from: RandomAgent.registerInitialState

Inspect the starting state.