Download SNePS 2.7 User`s Manual - University at Buffalo, Computer Science

Transcript
38
CHAPTER 4. SNERE: THE SNEPS RATIONAL ENGINE
* (describe (assert forall $person
ant
(build member *person class person)
cq
(build act (build action call object1 *person)
plan (build action snsequence
object1 (build action say
object1 "Come here")
object2 (build action say
object1 *person)))))
(M24! (FORALL V6) (ANT (P27 (CLASS PERSON) (MEMBER V6)))
(CQ
(P31 (ACT (P28 (ACTION CALL) (OBJECT1 V6)))
(PLAN
(P30 (ACTION SNSEQUENCE) (OBJECT1 (M23 (ACTION SAY) (OBJECT1 Come here)))
(OBJECT2 (P29 (ACTION SAY) (OBJECT1 V6))))))))
(M24!)
CPU time : 0.19
* (perform (build action achieve
object1 (build agent Bill state is location here)))
Come here
BILL
CPU time : 1.76
4.6 The Execution Cycle: Preconditions and Effects
SNeRE acting may be understood by the following pseudo-definition of perform, although the actual implemention is different.
perform(act):
preconds := set of preconditions of act;
unachieved-preconditions := preconds - {p | p ∈ precond & p is deduceable};
if unachieved-preconditions 6= nil
then perform(snsequence(doall({a | p ∈ unachieved-preconditions & a = achieve(p)}),
act))
else {effects := effects of act;
if act is primitive
then {apply(primitive-function(act), objects(act));
doall({a | p ∈ effects & a = believe(p)})}
else {plans := plans for carrying out act;
perform(snsequence(do-one(plans),
doall({a | p ∈ effects & a = believe(p)})))}}.
Notes and comments:
• A trace of the acting system is printed when the global variable *plantrace* is set to T. If *plantrace*
is set to ’surface, then nodes are sent to the GATN generator starting at state G for printing. If
*plantrace* is NIL, no trace is printed. This was the setting for the previous examples in this
chapter, but the default is T.
• The preconditions of an act, a are all p for which propositions of the form M!:{hact, ai, hprecondition,
pi} are deduceable.