// pseudo code for UNINFORMED STATE SPACE SEARCH WITH LOOP CHECKING
// That is, checking for already visited states. If a plan taken from the front
of the plan
// queue for expansion into successor plans evaluates to a state already visited
by another
// plan being considered, then we have already found a plan that visits this
state that is of
// equal or lower cost than the current plan. So discard this plan! (The
additional code
// for loop checking is in bold below, and consists of three steps (1), (2), and
(3) below.)
BEGIN
Create a Plan-Queue of plans.
Initialize Plan-Queue to empty.
Insert the empty-plan into the end of the Plan-Queue.
Get an initial state "S-init" and goal state "S-goal" from user.
Initialize List-Of-Visited-States to empty. (1)
Set boolean "solved" to False.
While(not solved)
{
Remove a plan from
the front of the Plan-Queue, call it plan P.
Run plan P on the
initial state S-init to get a final state "S-final"
If S-final == S-goal
then solved = True
else If ( legal_state (S_final) && NOT( Member(
S_final, List-Of-Visited-States)) ) (2)
then {
add S_final to List-Of-Visited-States
(3) generate all possible children of P
by generating all possible one step extensions of P
(for each possible operator)
add each child plan to the end of Plan-Queue
}
}
Output plan P to user
END