public override bool DropInt(Circumstance C, Literal goal, Unifier un) { Unifier bak = un.Clone(); bool isCurrentInt = false; IEnumerator <Intention> iint = C.GetAllIntentions(); while (iint.Current != null) { Intention i = iint.Current; IPlanBody pb = i.Peek().GetPlan().GetBody(); while (pb != null) { if (pb.GetBodyType() == BodyType.Body_Type.achieve || pb.GetBodyType() == BodyType.Body_Type.achieveNF) { if (un.Unifies(pb.GetBodyTerm(), goal)) { C.DropIntention(i); isCurrentInt = isCurrentInt || i.Equals(C.GetSelectedIntention()); un = bak.Clone(); break; } } pb = pb.GetBodyNext(); } } return(isCurrentInt); }
public override void Fail(Circumstance c) { if (Size() >= forkPoint && fd.isAnd) { // the fail is above fork, is an fork and, remove the others foreach (Intention ifo in fd.intentions) { c.DropIntention(ifo); } } }
/** * Drops an intention based on a goal argument * * returns true if the current intention is dropped */ public virtual bool DropInt(Circumstance C, Literal goal, Unifier un) { Unifier bak = un.Clone(); Trigger g = new Trigger(TEOperator.add, TEType.achieve, goal); bool isCurrentInt = false; IEnumerator <Intention> iint = C.GetAllIntentions(); while (iint.Current != null) { Intention i = iint.Current; if (i.HasTrigger(g, un)) { C.DropIntention(i); isCurrentInt = isCurrentInt || i.Equals(C.GetSelectedIntention()); un = bak.Clone(); } } return(isCurrentInt); }
public override KeyValuePair <Event, int> FindEventForFailure(Trigger tevent, PlanLibrary pl, Circumstance c) { KeyValuePair <Event, int> t = (KeyValuePair <Event, int>)base.FindEventForFailure(tevent, pl, c); if (t.Value <= forkPoint) { if (fd.isAnd) { fd.intentions.Remove(this); foreach (Intention ifo in fd.intentions) { c.DropIntention(ifo); } } else { return(new KeyValuePair <Event, int>(null, t.Value)); } } return(t); }