Inheritance: IComparable
Exemplo n.º 1
0
 /// <summary>
 /// Calculates a hashcode for a predicate
 /// </summary>
 /// <param name="predicate">Predicate to evaluate</param>
 /// <returns>Hashcode</returns>
 /// <remarks>Written separately so that it can be used for calculating hashes on predicat caching</remarks>
 protected static int CalculateHashCode(Predicate predicate)
 {
     return CalculateHashCode(predicate.Name, predicate.IsNegative, predicate.Parameters);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Are the Predicates Negatives of Eachother
        /// </summary>
        /// <param name="predicate">Predicate to Compare</param>
        /// <returns>True is the Predicate is the Compliment</returns>
        public bool IsComplimentOf(Predicate predicate)
        {
            bool result = false;

            if (Name == predicate.Name && IsNegative != predicate.IsNegative && Parameters.Count == predicate.Parameters.Count)
            {
                result = true;
                for (int i = 0; i < Parameters.Count; i++)
                {
                    if (Parameters[i] != predicate.Parameters[i])
                    {
                        result = false;
                        break;
                    }
                }
            }

            return result;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Adds a Predicate to the current cache
 /// </summary>
 /// <param name="predicate">Predicate to add</param>
 protected static void AddPredicate(Predicate predicate)
 {
     moPredicateCache[predicate.GetHashCode()] = predicate;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create an Action
 /// </summary>
 /// <param name="actionIdentity"></param>
 public Action(Predicate actionIdentity)
 {
     moActionIdentity = actionIdentity;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create a Predicate
 /// </summary>
 /// <param name="name">Name of Predicate</param>
 /// <param name="isNegative">Is Negative</param>
 /// <param name="parameters">Parameters</param>
 /// <returns>Predicate</returns>
 public static Predicate Create(string name, bool isNegative, params Term[] parameters)
 {
     Predicate predicate = Predicate.FindPredicate(name, isNegative, parameters);
     ConstantTerm ct = null;
     if (predicate == null)
     {
         predicate = new Predicate(name, isNegative, parameters);
         Predicate.AddPredicate(predicate);
     }
     return predicate;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Add a Precondition
 /// </summary>
 /// <param name="predicate">A Predicate to Add</param>
 public void AddPrecondition(Predicate predicate)
 {
     moPreconditionList.Add(predicate);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Add an Effect to the Effects
 /// </summary>
 /// <param name="predicate">A Predicate to Add</param>
 public void AddEffect(Predicate predicate)
 {
     moEffectList.Add(predicate);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Add a Causal Link
 /// </summary>
 /// <param name="from">From Action</param>
 /// <param name="achieves">The Predicate that Achieves</param>
 /// <param name="to">To Action</param>
 public void AddCausalLink(Action from, Predicate achieves, Action to)
 {
     moCausalLinks.Add(new CausalLink(from, achieves, to));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Create a Non-Primitive Task
 /// </summary>
 /// <param name="actionIdentity"></param>
 /// <param name="subTasks"></param>
 public Task(Predicate actionIdentity, params Task[] subTasks)
     : base(actionIdentity)
 {
     mbIsPrimitive = false;
     moSubTasks = new TaskList(subTasks);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Create a Task
 /// </summary>
 /// <param name="actionIdentity"></param>
 public Task(Predicate actionIdentity)
     : base(actionIdentity)
 {
     mbIsPrimitive = true;
 }