/****************************************************************************** * Find existing goals related to the emotion and alter their status if * necessary. * Examples: * in: [embarrassment J.] [suffocation J.] [pride J.] * sg->obj: [a-social-esteem J.] [s-air J.] [a-social-esteem J.] * old status: active-goal active-goal failed-goal * set status: failed-goal (no change) (no change) * result: 1 1 0 (irony?) ******************************************************************************/ Bool UA_Emotion_ExistingGoals(Actor *ac, Ts *ts, Obj *a, Obj *in) { int found; Obj *emot_class; Subgoal *sg; emot_class = I(in, 0); for (sg = ac->subgoals; sg; sg = sg->next) { if (SubgoalStateIsStopped(sg->state)) continue; if (sg->supergoal) continue; if (UA_Emotion_IsForGoal(N("success-emotion-of"), emot_class, sg->obj)) { found = 1; UA_GoalSetStatus(ac, sg, N("succeeded-goal"), in); } else if (UA_Emotion_IsForGoal(N("failure-emotion-of"), emot_class, sg->obj)) { found = 1; UA_GoalSetStatus(ac, sg, N("failed-goal"), in); } else if (UA_Emotion_IsForGoal(N("activated-emotion-of"), emot_class, sg->obj)) { found = 1; UA_GoalSetStatus(ac, sg, N("active-goal"), in); } } return(found); }
/****************************************************************************** * Top-level Goal Understanding Agent. ******************************************************************************/ void UA_Goal(Actor *ac, Ts *ts, Obj *a, Obj *in) { Obj *goal; Subgoal *sg; if (ISA(N("goal-status"), I(in, 0)) && a == I(in, 1)) { /* Goal is stated explicitly. * Examples: * [active-goal Jim [s-employment Jim]] * [succeeded-goal Jim [s-employment Jim]] * [failed-goal Jim [s-employment Jim]] * Note that emotional responses occur as a result of spinning * the goal. */ goal = I(in, 2); /* If <in> corresponds to existing subgoal, steer that subgoal according * to <in>. */ for (sg = ac->subgoals; sg; sg = sg->next) { if (ObjSimilarList(goal, sg->obj)) { UA_GoalSetStatus(ac, sg, I(in, 0), NULL); return; } } /* This is a new subgoal. */ /* todo: Add more heuristics for making sense. * For example, N("s-employment") doesn't make sense if <a> already has * a job. */ ContextSetRSN(ac->cx, RELEVANCE_TOTAL, SENSE_TOTAL, NOVELTY_TOTAL); if ((sg = TG(ac->cx, &ac->cx->story_time.stopts, a, goal))) { PA_SpinToGoalStatus(ac->cx, sg, I(in, 0), NULL); } } else if (ISA(N("prep-goal-for"), I(in, 0))) { UA_GoalSubgoal(ac, ts, a, in, I(in, 2), I(in, 1)); } else if (ISA(N("intends"), I(in, 0))) { UA_GoalSubgoal(ac, ts, a, in, I(in, 1), I(in, 2)); } }