Exemple #1
0
 public virtual float Score(IAIContext context, IList<IContextualScorer> scorers)
 {
   float num1 = 0.0f;
   int count = ((ICollection<IContextualScorer>) scorers).Count;
   for (int index = 0; index < count; ++index)
   {
     IContextualScorer scorer = scorers[index];
     if (!((ICanBeDisabled) scorer).get_isDisabled())
     {
       float num2 = scorer.Score(context);
       if ((double) num2 < 0.0)
       {
         Debug.LogWarning((object) "SumMustBeAboveThreshold scorer does not support scores below 0!");
       }
       else
       {
         num1 += num2;
         if ((double) num1 > (double) this.threshold)
           break;
       }
     }
   }
   if ((double) num1 <= (double) this.threshold)
     return 0.0f;
   return num1;
 }
Exemple #2
0
        public sealed override float Score(IAIContext context, IList <IContextualScorer> scorers)
        {
            float num   = 0f;
            int   count = scorers.Count;

            for (int i = 0; i < count; i++)
            {
                IContextualScorer contextualScorer = scorers[i];
                if (contextualScorer.isDisabled)
                {
                    continue;
                }
                float num2 = contextualScorer.Score(context);
                if (num2 < 0f)
                {
                    Debug.LogWarning("SumMustBeAboveThreshold scorer does not support scores below 0!");
                    continue;
                }
                num += num2;
                if (num > threshold)
                {
                    break;
                }
            }
            if (num <= threshold)
            {
                return(0f);
            }
            return(num);
        }
Exemple #3
0
        public sealed override float Score(IAIContext context, IList <IContextualScorer> scorers)
        {
            float single = 0f;
            int   count  = scorers.Count;

            for (int i = 0; i < count; i++)
            {
                IContextualScorer item = scorers[i];
                if (!item.isDisabled)
                {
                    float single1 = item.Score(context);
                    if (single1 >= 0f)
                    {
                        single += single1;
                        if (single > this.threshold)
                        {
                            break;
                        }
                    }
                    else
                    {
                        Debug.LogWarning("SumMustBeAboveThreshold scorer does not support scores below 0!");
                    }
                }
            }
            if (single <= this.threshold)
            {
                return(0f);
            }
            return(single);
        }
Exemple #4
0
        public sealed override bool Validate(IHTNContext context, IList <IContextualScorer> scorers)
        {
            int count = scorers.Count;

            for (int i = 0; i < count; i++)
            {
                IContextualScorer item = scorers[i];
                if (!item.isDisabled && item.CanInvalidatePlan && item.Score(context) <= this.threshold)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #5
0
        public sealed override float Score(IAIContext context, IList <IContextualScorer> scorers)
        {
            float single = 0f;
            int   count  = scorers.Count;

            for (int i = 0; i < count; i++)
            {
                IContextualScorer item = scorers[i];
                if (!item.isDisabled)
                {
                    single += item.Score(context);
                }
            }
            return(single);
        }
        /// <summary>
        /// Calculates a score given the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// The score.
        /// </returns>
        public float Score(IAIContext context)
        {
            var score = _scorer.Score(context);

            this.lastScore = score.ToString("f0");

            ICustomVisualizer customVisualizer;

            if (VisualizationManager.TryGetVisualizerFor(_scorer.GetType(), out customVisualizer))
            {
                customVisualizer.EntityUpdate(_scorer, context, _parent.parent.parent.id);
            }

            return(score);
        }