Information Technology Reference
In-Depth Information
Figure 9.7.
Generating plans for the monkey
?- plan([M1,M2,M3,M4]).
% Is there a four-step plan?
M1 = go(loc3)
M2 = push(loc1)
M3 = climb_on
M4 = grab
;
% Are there any others?
No
?- plan([M1,M2,M3]).
% Is there a three-step plan?
No
?- plan([M1,M2,M3,M4,M5]). % Is there a five-step plan?
M1 = go(_G325)
% First go to any location.
M2 = go(loc3)
% Then proceed as above.
M3 = push(loc1)
M4 = climb_on
M5 = grab
?- plan([M1,M2,M3,M4,M5]), \+ M1 = go(_).
No
?- plan(L).
ERROR: Out of global stack
The reason for this is that reachable looks for a path from an initial state S 0 to a goal
state G . A trace of the query would show the following:
1. The first action is a go action from state S 0 to a state S 1 , so the planner needs to
find a path from S 1 to G .
2. The next action is a go action from state S 1 to a state S 2 , so the planner needs to
find a path from S 2 to G . ...
In the end, the planner would look for ever longer sequences of go actions and never
get to the other moves. On the other hand, if the sequence were bounded in advance,
for instance, if the planner looked only for plans with four steps, then after four
go actions, the reachable predicate would fail, and the planner would be forced to
backtrack and consider other actions.
This suggests that it is useful to have a version of the general planner that first tries
[] , then [_] , then [_,_] , then [_,_,_] , and so on, until it finds a plan. There are a
few ways to do this, but perhaps the simplest is shown in figure 9.8. The new general
planner is called bplan . Its predicate tryplan (
holds if y is a successful plan and
is like x but possibly with some additional elements at the front. This predicate works
x , y
)
Search WWH ::




Custom Search