Page Numbers: Yes First Page: 1
Heading:
October 6, 1977 1:01 AM[IFS]<KRL>code>resultClasses.bravo
Status: first pass
[ResultClassPrototype ((self Goal)(message ResultMessage))
(* this is a function for a goal result)
(SELECTQ message
(SUCCEEDED (* self is goal, this represents one-shot success))
(FAILED (* self is goal))
(ABORTED (* self is goal))
(PARTIALLY-SUCCEEDED (* self is goal, result is bound))
(COMPLETED (* self is goal, follows previous partial success))
(HELP "bad message to goal result function")]
# # # # # # # # # # # # # # #
[ConjunctiveSubgoal ((self Goal)(message ResultMessage))
(* this is a function for a goal)
(DPROG((parent self:parent Goal) resultList partial? newResults)
(SELECTQ message
(SUCCEEDED
(if (for subgoal in parent:children
always (OR subgoal:results (EQ subgoal:goalStatus ’SUCCEEDED))
then (resultList ← parent:immediateResults)
(for subgoal in parent:children
when subgoal:results
do (if (NEQ subgoal:goalStatus ’SUCCEEDED)
then (partial? ← T))
(PUSH resultList subgoal:results))
(* in this case parent:results must be NIL, since one conjunct (this one) had never succeeded)
(if (NOT resultList)
then (GoalDone parent ’SUCCEEDED)
elseif (parent:results ← (IntersectResults resultList)))
then (if partial?
then (GoalPartiallySucceeded parent parent:results)
else (GoalDone parent ’SUCCEEDED))
else (GoalDone parent ’FAILED))))
(PARTIALLY-SUCCEEDED
(if (for subgoal in parent:children
always (OR subgoal:results (EQ subgoal:goalStatus ’SUCCEEDED))
then (resultList ← parent:immediateResults)
(for subgoal in parent:children
when (AND (NEQ subgoal self) subgoal:results)
do (PUSH resultList subgoal:results))
(if (newResults ← (IntersectResults <arg ! resultList>))
then (PUSHLIST parent:results newResults)
(GoalPartiallySucceeded parent newResults))))
(COMPLETED
(if (for subgoal in parent:children
always (EQ subgoal:goalStatus ’SUCCEEDED))
then (GoalDone parent ’SUCCEEDED)))
((FAILED ABORTED) (GoalDone parent ’FAILED))
(HELP "bad message to goal result function")]
# # # # # # # # # # # # # # #
[DisjunctiveSubgoal ((self Goal)(message ResultMessage))
(* this is a function for a goal result)
(PROG((parent self:parent) resultList partial? newResults oldResults)
(SELECTQ message
(SUCCEEDED
(if self:results
then (AddResultsToOr parent self:results))
(* note that this means that if one branch of an or succeeds with no actions
or bindings, the others may not be tried (depending on the order of succcess))
else (GoalDone parent ’SUCCEEDED)))
((FAILED ABORTED) (CheckDisjunctCompletion parent))
(PARTIALLY-SUCCEEDED (AddResultsToOr parent result))
(COMPLETED (CheckDisjunctCompletion parent))
(HELP "bad message to goal result function")]
# # # # # # # # # # # # # # #
[EquivalentGoal ((self Goal)(message ResultMessage))
(* this is a function for a goal result)
(PROG((parent self:parent))
(SELECTQ message
(SUCCEEDED (parent:results ← self:results) (GoalDone parent ’SUCCEEDED))
(FAILED (GoalDone parent ’FAILED))
(ABORTED)
(PARTIALLY-SUCCEEDED (GoalPartiallySucceeded parent result))
(COMPLETED (GoalDone parent ’COMPLETED))
(HELP "bad message to goal result function")]
# # # # # # # # # # # # # # #
[FindElementForEnumeration ((self Goal)(message ResultMessage))
(* this is a function for a goal result)
(SELECTQ message
(SUCCEEDED
(RPLACA (NTH self:parent:immediateResults self:goalDesc)
self:immediateResults)
(CheckEnumerationSatisfied parent))
((FAILED ABORTED)
(RPLACA (NTH self:parent:immediateResults self:goalDesc)
’UNKNOWN)
(CheckEnumerationSatisfied parent))
((PARTIALLY-SUCCEEDED COMPLETED)
(KHelp "partial results to leaf on goal tree -- enumeration" goal))
(HELP "bad message to goal result function")]
# # # # # # # # # # # # # # #
[FindForAction ((self Goal)(message ResultMessage))
(* this is a function for a goal result)
(SELECTQ message
(SUCCEEDED (RETFROM ’RunGoal self:immediateResults))
((FAILED ABORTED) (RETFROM ’RunGoal NIL))
((PARTIALLY-SUCCEEDED COMPLETED)
(KHelp "partial results to leaf on goal tree -- action" goal))
(HELP "bad message to goal result function")]
# # # # # # # # # # # # # # #
[FindForBinding ((self Goal)(message ResultMessage))
(* this is a function for a goal result)
(SELECTQ message
(SUCCEEDED
(self:results ←
<(Create Result
bindings ← <(CREATE Binding
bindingVariable ← goal:goalDesc:variableSpec
bindingValue ← self:immediateResults>)>)
(PUSH self:completeBindings goal:goalDesc:variableSpec)
(SendMessage ’ConjunctiveSubgoal self ’SUCCEEDED))
((FAILED ABORTED) (SendMessage ’ConjunctiveSubgoal self message))
((PARTIALLY-SUCCEEDED COMPLETED)
(KHelp "partial results to leaf on goal tree -- binding" goal))
(HELP "bad message to goal result function")]
# # # # # # # # # # # # # # #
[FindForCoreference ((self Goal)(message ResultMessage))
(* this is a function for a goal result)
(SELECTQ message
(SUCCEEDED (NewSubgoal self:parent ’AlignPost ??? ’EqivalentGoal)
(FAILED )
(ABORTED)
(PARTIALLY-SUCCEEDED)
(COMPLETED)
(HELP "bad message to goal result function")]
# # # # # # # # # # # # # # #
[InvertedGoal ((self Goal)(message ResultMessage))
(* this is a function for a goal result)
(PROG((parent self:parent))
(SELECTQ message
(SUCCEEDED (GoalDone parent ’FAILED))
(FAILED (GoalDone parent ’SUCCEEDED))
(ABORTED)
(PARTIALLY-SUCCEEDED (GoalDone parent ’FAILED))
(COMPLETED (KHelp "partial success should have killed me" goal))
(HELP "bad message to goal result function")]
# # # # # # # # # # # # # # #
[TopLevelGoal ((self Goal)(message ResultMessage))
(* this is a function for a goal result)
(SELECTQ message
(SUCCEEDED (if self:results then (SuccessfulResults self:results))
(AlignCompleted ’SUCCEED))
(FAILED (AlignCompleted ’FAIL))
(PARTIALLY-SUCCEEDED (SuccessfulResults results))
(COMPLETED (AlignCompleted ’SUCCEED))
(ABORTED (AlignCompleted ’ABORT)]