Example #1
0
        private List <Action> CreateReasoningActions(CompoundFormula cf)
        {
            List <Action>    lActions    = new List <Action>();
            Action           a           = null;
            List <Predicate> lPredicates = GetAllPredicates(cf);

            foreach (Predicate p in lPredicates)
            {
                a = new Action(cf.ToString() + "_" + p.ToString());
                a.Preconditions = new CompoundFormula("and");
                CompoundFormula cfEffects = new CompoundFormula("and");
                cfEffects.AddOperand(new PredicateFormula(new KnowPredicate(p)));
                foreach (Predicate pOther in lPredicates)
                {
                    if (pOther != p)
                    {
                        ((CompoundFormula)a.Preconditions).AddOperand(new PredicateFormula(new KnowPredicate(pOther)));
                    }
                }
                a.SetEffects(cfEffects);
                lActions.Add(a);
            }
            return(lActions);
        }