1111import aima .core .util .Util ;
1212
1313/**
14- * Modified copy of class {@code aima.search.framework.SimpleProblemSolvingAgent}.
15- * Here, attribute {@link #plan} (original: <code>seq</code>) is protected.
16- * Static pseudo code variable state is used in a more general
17- * sense including world state as well as agent state aspects.
18- * This allows the agent to change the plan, if unexpected percepts
19- * are observed. In the concrete java code, state corresponds with
20- * the agent instance itself (this).
21- * <pre><code>
14+ * Modified copy of class
15+ * {@link aima.search.framework.SimpleProblemSolvingAgent} which can be used for
16+ * online search, too. Here, attribute {@link #plan} (original:
17+ * <code>seq</code>) is protected. Static pseudo code variable state is used in
18+ * a more general sense including world state as well as agent state aspects.
19+ * This allows the agent to change the plan, if unexpected percepts are
20+ * observed. In the concrete java code, state corresponds with the agent
21+ * instance itself (this).
22+ *
23+ * <pre>
24+ * <code>
2225 * function PROBLEM-SOLVING-AGENT(percept) returns an action
2326 * inputs: percept, a percept
2427 * static: state, some description of current agent and world state
3639 * action <- FIRST(state.plan)
3740 * plan <- REST(state.plan)
3841 * return action
39- * </code></pre>
42+ * </code>
43+ * </pre>
4044 *
4145 * @author Ruediger Lunde
4246 *
4347 */
4448public abstract class ProblemSolvingAgent extends AbstractAgent {
45-
46- /** plan , an action sequence, initially empty. */
49+
50+ /** Plan , an action sequence, initially empty. */
4751 protected List <Action > plan = new ArrayList <Action >();
48-
52+
4953 public ProblemSolvingAgent () {
5054 }
5155
5256 /**
5357 * Template method, which corresponds to pseudo code function
54- * <code>MY-PROBLEM-SOLVING-AGENT(percept)</code>.
55- * returns an action
58+ * <code>PROBLEM-SOLVING-AGENT(percept)</code>.
59+ *
60+ * @return an action
5661 */
5762 public Action execute (Percept p ) {
5863 Action action ;
@@ -89,47 +94,45 @@ public Action execute(Percept p) {
8994 /**
9095 * Primitive operation, which decides after a search for a plan failed,
9196 * whether to stop the whole task with a failure, or to go on with
92- * formulating another goal. This implementation always returns false.
93- * If the agent defines local goals to reach an externally specified
94- * global goal, it might be interesting, not to stop when the first
95- * local goal turns out to be unreachable.
97+ * formulating another goal. This implementation always returns false. If
98+ * the agent defines local goals to reach an externally specified global
99+ * goal, it might be interesting, not to stop when the first local goal
100+ * turns out to be unreachable.
96101 */
97102 protected boolean tryWithAnotherGoal () {
98103 return false ;
99104 }
100-
105+
101106 //
102107 // ABSTRACT METHODS
103108 //
104109 /**
105- * Primitive operation, responsible for updating
106- * the state of the agent with respect to
107- * latest feedback from the world. In this version,
108- * implementations have access to the agent's current goal
109- * and plan, so they can modify them if needed. For
110- * example, if the plan didn't work because the model
111- * of the world proved to be wrong, implementations
112- * could update the model and also clear the plan.
110+ * Primitive operation, responsible for updating the state of the agent with
111+ * respect to latest feedback from the world. In this version,
112+ * implementations have access to the agent's current goal and plan, so they
113+ * can modify them if needed. For example, if the plan didn't work because
114+ * the model of the world proved to be wrong, implementations could update
115+ * the model and also clear the plan.
113116 */
114117 protected abstract Object updateState (Percept p );
115118
116119 /**
117- * Primitive operation, responsible for goal generation. In this
118- * version, implementations are allowed to return null to indicate
119- * that the agent has finished the job an should die.
120- * Implementations can access the current goal (which is
121- * a possibly modified version of the last formulated goal).
122- * This might be useful in situations in which plan execution
123- * has failed.
120+ * Primitive operation, responsible for goal generation. In this version,
121+ * implementations are allowed to return null to indicate that the agent has
122+ * finished the job an should die. Implementations can access the current
123+ * goal (which is a possibly modified version of the last formulated goal).
124+ * This might be useful in situations in which plan execution has failed.
124125 */
125126 protected abstract Object formulateGoal ();
127+
126128 /**
127129 * Primitive operation, responsible for search problem generation.
128130 */
129131 protected abstract Problem formulateProblem (Object goal );
132+
130133 /**
131- * Primitive operation, responsible for the generation of an action
132- * list (plan) for the given search problem.
134+ * Primitive operation, responsible for the generation of an action list
135+ * (plan) for the given search problem.
133136 */
134137 protected abstract List <Action > search (Problem problem );
135138}
0 commit comments