Module pacai.agents.search.staydirection
Classes
class StayEastSearchAgent (index, **kwargs)
-
Expand source code
class StayEastSearchAgent(SearchAgent): """ An agent for `pacai.core.search.position.PositionSearchProblem` with a cost function that penalizes being on the West side of the board. The cost function for stepping into a position (x, y) is `(1/2)^x`. """ def __init__(self, index, **kwargs): costFn = lambda pos: 0.5 ** pos[0] super().__init__(index, fn = search.ucs, prob = lambda state: PositionSearchProblem(state, costFn), **kwargs)
An agent for
PositionSearchProblem
with a cost function that penalizes being on the West side of the board.The cost function for stepping into a position (x, y) is
(1/2)^x
.Ancestors
- SearchAgent
- BaseAgent
- abc.ABC
Static methods
def loadAgent(name, index, args={})
-
Inherited from:
SearchAgent
.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:
SearchAgent
.final
Inform the agent about the result of a game.
def getAction(self, state)
-
Inherited from:
SearchAgent
.getAction
Returns the next action in the path chosen earlier (in registerInitialState). Return Directions.STOP if there is no further action to take.
def observationFunction(self, state)
-
Inherited from:
SearchAgent
.observationFunction
Make an observation on the state of the game. Called once for each round of the game.
def registerInitialState(self, state)
-
Inherited from:
SearchAgent
.registerInitialState
This is the first time that the agent sees the layout of the game board. Here, we choose a path to the goal. In this phase, the agent should compute …
class StayWestSearchAgent (index, **kwargs)
-
Expand source code
class StayWestSearchAgent(SearchAgent): """ An agent for `pacai.core.search.position.PositionSearchProblem` with a cost function that penalizes being on the East side of the board. The cost function for stepping into a position (x, y) is `2^x`. """ def __init__(self, index, **kwargs): costFn = lambda pos: 2 ** pos[0] super().__init__(index, fn = search.ucs, prob = lambda state: PositionSearchProblem(state, costFn), **kwargs)
An agent for
PositionSearchProblem
with a cost function that penalizes being on the East side of the board.The cost function for stepping into a position (x, y) is
2^x
.Ancestors
- SearchAgent
- BaseAgent
- abc.ABC
Static methods
def loadAgent(name, index, args={})
-
Inherited from:
SearchAgent
.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:
SearchAgent
.final
Inform the agent about the result of a game.
def getAction(self, state)
-
Inherited from:
SearchAgent
.getAction
Returns the next action in the path chosen earlier (in registerInitialState). Return Directions.STOP if there is no further action to take.
def observationFunction(self, state)
-
Inherited from:
SearchAgent
.observationFunction
Make an observation on the state of the game. Called once for each round of the game.
def registerInitialState(self, state)
-
Inherited from:
SearchAgent
.registerInitialState
This is the first time that the agent sees the layout of the game board. Here, we choose a path to the goal. In this phase, the agent should compute …