Example #1
0
        private Action CreateReasoningAction(Predicate pEffect, HashSet <Predicate> lPredicates)
        {
            KnowPredicate kpEffect = new KnowPredicate(pEffect);

            if (Predicates.Contains(kpEffect))
            {
                return(null);
            }
            Action a = new KnowledgeAction("Reasoning_" + pEffect.ToString());

            a.Preconditions = new CompoundFormula("and");
            foreach (Predicate pOther in lPredicates)
            {
                if (pOther != pEffect)
                {
                    KnowPredicate kp = new KnowPredicate(pOther);
                    if (!Predicates.Contains(kp))
                    {
                        return(null);
                    }
                    ((CompoundFormula)a.Preconditions).AddOperand(new PredicateFormula(kp));
                }
            }
            CompoundFormula cfEffects = new CompoundFormula("and");

            cfEffects.AddOperand(new PredicateFormula(kpEffect));
            a.SetEffects(cfEffects);
            return(a);
        }
Example #2
0
 public bool Contains(Predicate p)
 {
     if (p.Negation)
     {
         return(!Predicates.Contains(p.Negate()));
     }
     return(Predicates.Contains(p));
 }
Example #3
0
 /// <summary>
 /// Checks whether the state contains the given predicate.
 /// </summary>
 /// <param name="predicate">Predicate to be checked.</param>
 /// <returns>True if the state contains the predicate, false otherwise.</returns>
 public bool HasPredicate(IAtom predicate)
 {
     if (Predicates == null)
     {
         return(false);
     }
     return(Predicates.Contains(predicate));
 }
Example #4
0
        public ail.net.parser.FsaTransition AddTransition(int xi_start, int xi_end, string xi_predicate, char xi_switch_char, string xi_context, int xi_rank)
        {
            ail.net.framework.Assert.NonEmptyString(xi_predicate, "xi_predicate");

            ail.net.parser.FsaTransition result = null;

            ail.net.parser.FsaState state = (ail.net.parser.FsaState)States[xi_start];
            ail.net.framework.Assert.NonNullReference(state, "state");

            int transition_id = TransitionCounter.Next();

            result = new ail.net.parser.FsaTransition(transition_id, xi_start, xi_end, xi_predicate, xi_switch_char, xi_context, xi_rank);

            state.Transitions.Add(transition_id, result);

            if (!Predicates.Contains(xi_predicate))
            {
                Predicates.Add(xi_predicate, result.Predicate);
            }

            return(result);
        }
Example #5
0
        public override bool Equals(object obj)
        {
            if (obj is State)
            {
                State s = (State)obj;
                if (s.m_lPredicates.Count != m_lPredicates.Count)
                {
                    return(false);
                }

                foreach (Predicate p in s.Predicates)
                {
                    if (!Predicates.Contains(p))
                    {
                        return(false);
                    }
                }
                return(true);

                //return m_lPredicates.Equals(s.m_lPredicates);
            }
            return(false);
        }
Example #6
0
 public bool Contains(Predicate <T> item)
 {
     return(Predicates.Contains(item));
 }