public abstract class ProblemSolvingAgent extends AbstractAgent
aima.search.framework.SimpleProblemSolvingAgent which can be used for
online search, too. Here, attribute plan (original:
seq) is protected. Static pseudo code variable state is used in
a more general sense including world state as well as agent state aspects.
This allows the agent to change the plan, if unexpected percepts are
observed. In the concrete java code, state corresponds with the agent
instance itself (this).
function PROBLEM-SOLVING-AGENT(percept) returns an action
inputs: percept, a percept
static: state, some description of current agent and world state
state <- UPDATE-STATE(state, percept)
while (state.plan is empty) do
goal <- FORMULATE-GOAL(state)
if (goal != null) then
problem <- FORMULATE-PROBLEM(state, goal)
state.plan <- SEARCH(problem)
if (state.plan is empty and !tryWithAnotherGoal()) then
add NO_OP to plan // failure
else
add NO_OP to plan // success
action <- FIRST(state.plan)
plan <- REST(state.plan)
return action
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<Action> |
plan
Plan, an action sequence, initially empty.
|
program| Constructor and Description |
|---|
ProblemSolvingAgent() |
| Modifier and Type | Method and Description |
|---|---|
Action |
execute(Percept p)
Template method, which corresponds to pseudo code function
PROBLEM-SOLVING-AGENT(percept). |
protected abstract java.lang.Object |
formulateGoal()
Primitive operation, responsible for goal generation.
|
protected abstract Problem |
formulateProblem(java.lang.Object goal)
Primitive operation, responsible for search problem generation.
|
protected abstract java.util.List<Action> |
search(Problem problem)
Primitive operation, responsible for the generation of an action list
(plan) for the given search problem.
|
protected boolean |
tryWithAnotherGoal()
Primitive operation, which decides after a search for a plan failed,
whether to stop the whole task with a failure, or to go on with
formulating another goal.
|
protected abstract java.lang.Object |
updateState(Percept p)
Primitive operation, responsible for updating the state of the agent with
respect to latest feedback from the world.
|
isAlive, setAliveprotected java.util.List<Action> plan
public Action execute(Percept p)
PROBLEM-SOLVING-AGENT(percept).execute in interface Agentexecute in class AbstractAgentp - The current percept of a sequence perceived by the Agent.protected boolean tryWithAnotherGoal()
protected abstract java.lang.Object updateState(Percept p)
protected abstract java.lang.Object formulateGoal()
protected abstract Problem formulateProblem(java.lang.Object goal)