Esempio n. 1
0
        private void AddKnowledgePredicatesToExistingActions(Domain d, List <Predicate> lKnowPredicates)
        {
            Actions = new List <Action>();
            ParametrizedAction aRevised = null;

            foreach (Action a in d.Actions)
            {
                aRevised = new ParametrizedAction(a.Name);
                aRevised.Preconditions = AddKnowledgePredicatesToFormula(a.Preconditions, lKnowPredicates);
                CompoundFormula cfEffects = null;
                if (a.Effects != null)
                {
                    cfEffects = AddKnowledgePredicatesToFormula(a.Effects, lKnowPredicates);
                }
                else
                {
                    cfEffects = new CompoundFormula("and");
                }
                if (a.Observe != null)
                {
                    List <Predicate> lPredicates = GetAllPredicates(a.Observe);
                    foreach (Predicate p in lPredicates)
                    {
                        cfEffects.AddOperand(new PredicateFormula(new KnowPredicate(p)));
                    }
                }
                aRevised.SetEffects(cfEffects);
                Actions.Add(aRevised);
            }
        }
Esempio n. 2
0
        public override Action Clone()
        {
            ParametrizedAction aNew = new ParametrizedAction(Name);

            aNew.Parameters = Parameters;
            if (Preconditions != null)
            {
                aNew.Preconditions = Preconditions.Clone();
            }
            if (Effects != null)
            {
                aNew.SetEffects(Effects.Clone());
            }
            if (Observe != null)
            {
                aNew.Observe = Observe.Clone();
            }
            aNew.HasConditionalEffects          = HasConditionalEffects;
            aNew.ContainsNonDeterministicEffect = ContainsNonDeterministicEffect;
            return(aNew);
        }