public int Buf(List <Literal> percepts) { if (percepts == null) { return(0); } int adds = 0; int dels = 0; HashSet <StructureWrapperForLiteral> perW = new HashSet <StructureWrapperForLiteral>(); IEnumerator <Literal> iper = percepts.GetEnumerator(); while (iper.MoveNext()) { perW.Add(new StructureWrapperForLiteral(iper.Current)); } IEnumerator <Literal> perceptsInBB = GetBB().GetPercepts(); while (perceptsInBB.MoveNext()) { Literal l = perceptsInBB.Current; if (l.SubjectToBUF() && !perW.Remove(new StructureWrapperForLiteral(l))) { dels++; perceptsInBB.Dispose(); Trigger te = new Trigger(TEOperator.del, TEType.belief, l); if (reasoner.GetCircumstance().HasListener() || pl.HasCandidatePlan(te)) { l = AsSyntax.AsSyntax.CreateLiteral(l.GetFunctor(), l.GetTermsArray()); l.AddAnnot(BeliefBase.TPercept); te.SetLiteral(l); reasoner.GetCircumstance().AddEvent(new Event(te, Intention.emptyInt)); } } } foreach (StructureWrapperForLiteral lw in perW) { try { Literal lp = lw.GetLiteral().Copy().ForceFullLiteralImpl(); lp.AddAnnot(BeliefBase.TPercept); if (GetBB().Add(lp)) { adds++; reasoner.UpdateEvents(new Event(new Trigger(TEOperator.add, TEType.belief, lp), Intention.emptyInt)); } } catch (Exception e) { //logger.log(Level.SEVERE, "Error adding percetion " + lw.getLiteral(), e); } } return(adds + dels); }
public override object Execute(Reasoner ts, Unifier un, ITerm[] args) { CheckArguments(args); List <Literal>[] result = ts.GetAgent().Brf((Literal)args[0], null, null, true); if (result != null) { ts.UpdateEvents(result, null); } return(true); }
public override object Execute(Reasoner ts, Unifier un, ITerm[] args) { CheckArguments(args); Literal l = (Literal)args[0]; if (!l.HasSource()) { l.AddAnnot(BeliefBase.TSelf); } List <Literal>[] result = ts.GetAgent().Brf(l, null, null, false); if (result != null) { ts.UpdateEvents(result, null); } return(true); }