Ejemplo n.º 1
0
        /// <summary>
        /// Applies the effect backwards to the given conditions.
        /// </summary>
        /// <param name="conditions">Conditions.</param>
        public override IConditions ApplyBackwards(IConditions conditions)
        {
            if (IsRelevant(conditions) == EffectRelevance.RELEVANT)
            {
                IConditions newConditions = (IConditions)conditions.Clone();
                newConditions.RemoveConstraint(Assignment);
                newConditions = newConditions.ConjunctionWith(Conditions);

                return(conditions.DisjunctionWith(newConditions));
            }
            return(conditions);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a disjunction of the current conditions and the specified other conditions.
        /// </summary>
        /// <param name="other">Other conditions.</param>
        /// <returns>Disjunction of the current conditions and the given other conditions.</returns>
        public IConditions DisjunctionWith(IConditions other)
        {
            if (Count == 0)
            {
                // empty conditions always evaluate as true, so any disjunction with this conditions
                // would also be a tautology -> we don't create a clause in this case and just return
                return((IConditions)Clone());
            }

            if (other is ConditionsClause || other is ConditionsContradiction)
            {
                return(other.DisjunctionWith(this));
            }

            Debug.Assert(other is Conditions);
            return(new ConditionsClause((Conditions)Clone(), (Conditions)other.Clone()));
        }