public class LRTAStarAgent extends AbstractAgent
function LRTA*-AGENT(s') returns an action inputs: s', a percept that identifies the current state persistent: result, a table, indexed by state and action, initially empty H, a table of cost estimates indexed by state, initially empty s, a, the previous state and action, initially null if GOAL-TEST(s') then return stop if s' is a new state (not in H) then H[s'] <- h(s') if s is not null result[s, a] <- s' H[s] <- min LRTA*-COST(s, b, result[s, b], H) b (element of) ACTIONS(s) a <- an action b in ACTIONS(s') that minimizes LRTA*-COST(s', b, result[s', b], H) s <- s' return a function LRTA*-COST(s, a, s', H) returns a cost estimate if s' is undefined then return h(s) else return c(s, a, s') + H[s']Figure 4.24 LRTA*-AGENT selects an action according to the value of neighboring states, which are updated as the agent moves about the state space.
program
Constructor and Description |
---|
LRTAStarAgent(OnlineSearchProblem problem,
PerceptToStateFunction ptsFunction,
HeuristicFunction hf)
Constructs a LRTA* agent with the specified search problem, percept to
state function, and heuristic function.
|
Modifier and Type | Method and Description |
---|---|
Action |
execute(Percept psDelta)
Call the Agent's program, which maps any given percept sequences to an
action.
|
HeuristicFunction |
getHeuristicFunction()
Returns the heuristic function of this agent.
|
PerceptToStateFunction |
getPerceptToStateFunction()
Returns the percept to state function of this agent.
|
OnlineSearchProblem |
getProblem()
Returns the search problem of this agent.
|
void |
setHeuristicFunction(HeuristicFunction hf)
Sets the heuristic function of this agent.
|
void |
setPerceptToStateFunction(PerceptToStateFunction ptsFunction)
Sets the percept to state function of this agent.
|
void |
setProblem(OnlineSearchProblem problem)
Sets the search problem for this agent to solve.
|
isAlive, setAlive
public LRTAStarAgent(OnlineSearchProblem problem, PerceptToStateFunction ptsFunction, HeuristicFunction hf)
problem
- an online search problem for this agent to solve.ptsFunction
- a function which returns the problem state associated with a
given Percept.hf
- heuristic function h(n), which estimates the cost of
the cheapest path from the state at node n to a goal
state.public OnlineSearchProblem getProblem()
public void setProblem(OnlineSearchProblem problem)
problem
- the search problem for this agent to solve.public PerceptToStateFunction getPerceptToStateFunction()
public void setPerceptToStateFunction(PerceptToStateFunction ptsFunction)
ptsFunction
- a function which returns the problem state associated with a
given Percept.public HeuristicFunction getHeuristicFunction()
public void setHeuristicFunction(HeuristicFunction hf)
hf
- heuristic function h(n), which estimates the cost of
the cheapest path from the state at node n to a goal
state.public Action execute(Percept psDelta)
Agent
execute
in interface Agent
execute
in class AbstractAgent
psDelta
- The current percept of a sequence perceived by the Agent.