Exemple #1
0
        /// <summary>
        /// Evaluates <see cref="Decision"/> that represent the Quality of this rule in relation to the entities current situation.
        /// </summary>
        /// <param name="controller"></param>
        /// <returns>value representing Quality. Higher means more likely to be the right decision.</returns>
        public float MakeQualityDecision(RuleController controller)
        {
            Decision quality = GetDecisionByIdentifier(QualityId);

            Quality = quality.Make(controller, this);
            return(Quality);
        }
        public override float Evaluate(RuleController controller, Rule rule, Decision decision)
        {
            float total = 1f;

            foreach (int input in decision.inputID)
            {
                total *= rule.GetDecisionByIdentifier(input).Make(controller, rule);
            }
            return(total);
        }
Exemple #3
0
 // Makes Quality Decision for an implicit Action.
 public override float Evaluate(RuleController controller, Rule rule, Decision decision)
 {
     // Do decision logic here.
     if (decision.inputID.Length == 2)
     {
         float a = rule.GetDecisionByIdentifier(decision.inputID[0]).Make(controller, rule);
         float b = rule.GetDecisionByIdentifier(decision.inputID[1]).Make(controller, rule);
         return((a < b) ? 1 : 0);
     }
     return(0);
 }
 public override float Evaluate(RuleController controller, Rule rule, Decision decision)
 {
     foreach (int input in decision.inputID)
     {
         if (rule.GetDecisionByIdentifier(input).Make(controller, rule) == 1)
         {
             return(1f);
         }
     }
     return(0f);
 }
Exemple #5
0
 // Makes Quality Decision for an implicit Action.
 public override float Evaluate(RuleController controller, Rule rule, Decision decision)
 {
     // Do decision logic here.
     if (decision.inputID.Length > 1)
     {
         float value = rule.GetDecisionByIdentifier(decision.inputID[0]).Make(controller, rule);
         for (int i = 1; i < decision.inputID.Length; i++)
         {
             if (rule.GetDecisionByIdentifier(decision.inputID[i]).Make(controller, rule) != value)
             {
                 return(0);
             }
         }
         return(1);
     }
     return(0);
 }
        // Makes Quality Decision for an implicit Action.
        public override float Evaluate(RuleController controller, Rule rule, Decision decision)
        {
            if (decision.inputID.Length > 1)
            {
                float total = rule.GetDecisionByIdentifier(decision.inputID[0]).Make(controller, rule);

                for (int i = 1; i < decision.inputID.Length; i++)
                {
                    total /= rule.GetDecisionByIdentifier(decision.inputID[i]).Make(controller, rule);
                }
                return(total);
            }
            else if (decision.inputID.Length == 1)
            {
                return(rule.GetDecisionByIdentifier(decision.inputID[0]).Make(controller, rule));
            }
            return(0f);
        }
Exemple #7
0
        /// <summary>
        /// Evaluates <see cref="Decision"/> that represent Mandatory conditions for an <see cref="Action"/> to work.
        /// </summary>
        /// <param name="controller"> Reference to the <see cref="RuleController"/> that evaluates this rule.</param>
        /// <returns>true when action is executable.</returns>
        public bool CanRuleBeExecuted(RuleController controller)
        {
            Decision mandatory = GetDecisionByIdentifier(MandatoryId);

            return((mandatory.Make(controller, this) > 0) ? true : false);
        }
Exemple #8
0
 /// <summary>
 /// Triggers evaluation function within <see cref="Statement"/>.
 /// </summary>
 /// <param name="controller"><see cref="RuleController"/> triggering evaluation. </param>
 /// <param name="rule"><see cref="Rule"/> refrence to rule containing this decisison. </param>
 /// <returns></returns>
 public float Make(RuleController controller, Rule rule)
 {
     return(Operator.Evaluate(controller, rule, this));
 }
 public override float Evaluate(RuleController controller, Rule rule, Decision decision)
 {
     return(decision.FlatValue);
 }
Exemple #10
0
 /// <summary>
 /// Evaluation whether this action has completed for this <see cref="RuleController"/>.
 /// </summary>
 /// <param name="controller"><see cref="GameObject"/> calling this action. </param>
 /// <returns></returns>
 public abstract bool IsComplete(RuleController controller);
Exemple #11
0
 /// <summary>
 /// Run once exit Action. Used post-execute loop.
 /// </summary>
 /// <param name="controller"><see cref="GameObject"/> calling this action. </param>
 public abstract void OnExitAction(RuleController controller);
Exemple #12
0
 /// <summary>
 /// Main functionality loop. Run while action is active.
 /// </summary>
 /// <param name="controller"><see cref="GameObject"/> calling this action. </param>
 public abstract void Execute(RuleController controller);
Exemple #13
0
 /// <summary>
 /// Run once entry Action. Used pre-execute loop.
 /// </summary>
 /// <param name="controller"><see cref="GameObject"/> calling this action. </param>
 public abstract void OnEnterAction(RuleController controller);
Exemple #14
0
 public abstract float Evaluate(RuleController controller, Rule rule, Decision decision);