Beispiel #1
0
 /// <summary>
 /// Checks the equality with other assigned value.
 /// </summary>
 /// <param name="other">Other assigned value.</param>
 /// <returns>True if the objects are equal, false otherwise.</returns>
 public bool Equals(IAssignment other)
 {
     if (other == this)
     {
         return(true);
     }
     return(Variable == other.GetVariable() && Value == other.GetValue());
 }
Beispiel #2
0
 /// <summary>
 /// Checks whether the specified variable is actually affected by the operator effects. If the check is positive, returns
 /// also the effect application value.
 /// </summary>
 /// <param name="variable">Variable to be checked.</param>
 /// <param name="value">Applied value.</param>
 /// <returns>True if the given variable is affected by the effects, false otherwise.</returns>
 public bool IsVariableAffected(int variable, out int value)
 {
     foreach (var effect in this)
     {
         IAssignment assignment = effect.GetAssignment();
         if (assignment.GetVariable() == variable)
         {
             value = assignment.GetValue();
             return(true);
         }
     }
     value = Assignment.InvalidValue;
     return(false);
 }
Beispiel #3
0
        /// <summary>
        /// Tries to unlocked the specified mutex item, if the assignment changes the value of currently locked item.
        /// </summary>
        /// <param name="groupIndex">Mutex group index.</param>
        /// <param name="assignment">Effect assignment.</param>
        /// <returns>True, if the specified group item was unlocked, false otherwise.</returns>
        private bool TryUnlockAlteredMutexItem(int groupIndex, IAssignment assignment)
        {
            int lockedItem = Locks[groupIndex];

            if (lockedItem == -1)
            {
                return(true);
            }

            var mutexGroup = MutexGroups[groupIndex];

            if (assignment.GetVariable() == mutexGroup[lockedItem].GetVariable())
            {
                Locks[groupIndex] = -1;
                return(true);
            }

            return(false);
        }
Beispiel #4
0
 /// <summary>
 /// Checks whether the state has the specified assignment.
 /// </summary>
 /// <param name="assignment">Assignment ot be checked.</param>
 /// <returns>True if the state has the given assignment, false otherwise.</returns>
 public bool HasValue(IAssignment assignment)
 {
     return(HasValue(assignment.GetVariable(), assignment.GetValue()));
 }
Beispiel #5
0
 /// <summary>
 /// Sets the specified assignment in the state.
 /// </summary>
 /// <param name="assignment">Assignment ot be checked.</param>
 public void SetValue(IAssignment assignment)
 {
     SetValue(assignment.GetVariable(), assignment.GetValue());
 }