Update: substitute vars in the derived goals as well
@@ -154,9 +154,12 @@ static Decision Cycle_PropagateSubgoals(long currentTime)
{
Concept *c = chain->c;
chain = chain->next;
- if(c != NULL && c->processID != conceptProcessID && Variable_Unify(&c->term, &goal->term).success) //could be <a --> M>! matching to some <... =/> <$1 --> M>>.
+ if(c != NULL && c->processID != conceptProcessID)
{
c->processID = conceptProcessID;
+ Substitution subs = Variable_Unify(&c->term, &goal->term);
+ if(subs.success) //could be <a --> M>! matching to some <... =/> <$1 --> M>>.
+ {
bool revised;
c->goal_spike = Inference_RevisionAndChoice(&c->goal_spike, goal, currentTime, &revised);
for(int opi=0; opi<=OPERATIONS_MAX; opi++)
@@ -172,6 +175,10 @@ static Decision Cycle_PropagateSubgoals(long currentTime)
}
Event newGoal = Inference_GoalDeduction(&c->goal_spike, imp);
Event newGoalUpdated = Inference_EventUpdate(&newGoal, currentTime);
+ bool success;
+ newGoalUpdated.term = Variable_ApplySubstitute(newGoalUpdated.term, subs, &success);
+ if(success)
+ {
IN_DEBUG( fputs("derived goal ", stdout); Narsese_PrintTerm(&newGoalUpdated.term); puts(""); )
Memory_AddEvent(&newGoalUpdated, currentTime, selectedGoalsPriority[i] * Truth_Expectation(newGoalUpdated.truth), 0, false, true, false, false, false);
}
@@ -180,6 +187,8 @@ static Decision Cycle_PropagateSubgoals(long currentTime)
}
}
}
+ }
+ }
return best_decision;
}
