Information Technology Reference
In-Depth Information
The monkey is on the box if it has just climbed on the box or if it was already on it and
did not just climb off. To characterize a person as being married or single, the pattern
will be exactly the same except that getting married makes being married true, and
getting divorced makes it false:
married(X,[get_married(X)|_]).
married(X,[A|S]) :- \+ A=get_divorced(X), married(X,S).
There might be a fluent that can be made true and then stays true thereafter. For
example, there was no action in this world for the monkey to dispose of the bananas
after grabbing them. So the following successor state clauses apply:
has_bananas([grab|_]).
has_bananas([_|S]) :- has_bananas(S).
Once the monkey has performed a grab action, it has the bananas and will continue
to have them no matter what action is performed next. Similarly, in this world, the
location of the bananas is unaffected by any action:
location(bananas,loc1,[]). % The initial location
location(bananas,L,[_|S]) :- location(bananas,L,S).
More concisely, the location of the bananas can be characterized as being the same as
the initial location in all situations:
location(bananas,loc1,_).
The final fluent needed is the location of the monkey. This is just like the location of
the box, except that it is affected by both push and go actions:
location(monkey,loc2,[]).
location(monkey,L,[push(L)|_]).
location(monkey,L,[go(L)|_]).
location(monkey,L,[A|S]) :-
\+ A=push(_), \+ A=go(_), location(monkey,L,S).
In other words, the monkey is at a location if it just went or pushed the box there, or
if it was already there and did not just go or push the box to somewhere else.
Action precondition clauses
The only thing left to do to fully characterize a world in terms of situations and
fluents is to state the conditions under which it is possible to perform an action. This
was done implicitly in the legal_move predicate, but here it is useful to state these
 
Search WWH ::




Custom Search