Exemplo n.º 1
0
 public static Trigger TryToGetTrigger(ITerm t)
 {
     if (t.GetType() == typeof(Trigger))
     {
         return((Trigger)t);
     }
     if (t.IsPlanBody())
     {
         IPlanBody p = (IPlanBody)t;
         if (p.GetPlanSize() == 1)
         {
             TEOperator op = null;
             if (p.GetBodyType() == BodyType.Body_Type.addBel)
             {
                 op = TEOperator.add;
             }
             else if (p.GetBodyType() == BodyType.Body_Type.delBel)
             {
                 op = TEOperator.del;
             }
             if (op != null)
             {
                 Literal l = ((Literal)p.GetBodyTerm().Clone()).ForceFullLiteralImpl();
                 l.DelAnnot(BeliefBase.TSelf);
                 return(new Trigger(op, TEType.belief, l));
             }
         }
     }
     if (t.IsString())
     {
         return(AsSyntax.ParseTrigger(((IStringTerm)t).GetString()));
     }
     return(null);
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 // Used by if/for/loop internal actions
 public IPlanBody InsertAsNextStep(IPlanBody pb)
 {
     planBody = new PlanBodyImpl(planBody.GetBodyType(), planBody.GetBodyTerm());
     planBody.SetBodyNext(pb);
     return(planBody);
 }