public IEnumerator <Unifier> LogicalConsecuence(Agent ag, Unifier un) { if (ag == null || ag.GetReasoner().GetUserAgArch().IsRunning()) { try { InternalAction ia = GetIA(ag); if (!ia.CanBeUsedInContext()) { Debug.Log(GetErrorMsg() + ": internal action" + GetFunctor() + " cannot be used in context or rules"); return(LogExpr.EMPTY_UNIF_LIST.GetEnumerator()); } //calls IA's execute method object oresult = ia.Execute(ag.GetReasoner(), un, ia.PrepareArguments(this, un)); if (oresult.GetType() == typeof(bool) && (bool)oresult) { return(LogExpr.CreateUnifEnumerator(un)); } else if (oresult.GetType() == typeof(IEnumerator <>)) { return((IEnumerator <Unifier>)oresult); } } catch (Exception e) { Debug.Log("*-*-*" + GetFunctor() + " concurrent exception - try later" + e.ToString()); try { Thread.Sleep(2000); } catch (Exception e1) { return(LogicalConsecuence(ag, un)); } } } return(LogExpr.EMPTY_UNIF_LIST.GetEnumerator()); }
public override IEnumerator <Unifier> LogicalConsequence(Agent ag, Unifier un) { return(LogExpr.CreateUnifEnumerator(un)); }