示例#1
0
    public void ChoiceGoalFromEvaluator(Brain brain)
    {
        GoalEvaluator goalEvaluator = null;
        float         num           = 0f;
        int           i             = 0;

        for (int count = evaluators.Count; i < count; i++)
        {
            GoalEvaluator goalEvaluator2 = evaluators[i];
            if (FlagIsOn((EVAL_FLAG)(1 << i)))
            {
                float num2 = goalEvaluator2.CalcEvaluateValue(brain);
                if (num2 > num)
                {
                    num           = num2;
                    goalEvaluator = goalEvaluator2;
                }
            }
        }
        if (goalEvaluator != null)
        {
            goalEvaluator.SetGoal(brain, this);
        }
        else if (GetCountSubGoal() <= 0)
        {
            AddGoal_Stop();
        }
    }
示例#2
0
        private void Arbitrate()
        {
            int count = this._evaluators.Count;

            if (count == 0)
            {
                return;
            }

            float         best          = 0;
            GoalEvaluator mostDesirable = null;

            for (int i = 0; i < count; i++)
            {
                GoalEvaluator evaluator    = this._evaluators[i];
                float         desirability = evaluator.CalculateDesirability();
                if (desirability > best)
                {
                    best          = desirability;
                    mostDesirable = evaluator;
                }
            }

            mostDesirable?.SetGoal();
        }
示例#3
0
        public void Rearbitrate()
        {
            this.previous = Type.Undefined;
            this.RemoveAllSubgoals();
            int count = this._evaluators.Count;

            for (int i = 0; i < count; i++)
            {
                GoalEvaluator evaluator = this._evaluators[i];
                evaluator.Reset();
            }
            this._status = Status.Inactive;
        }
示例#4
0
        public GoalEvaluator GetEvaluator <T>() where T : GoalEvaluator
        {
            int count = this._evaluators.Count;

            for (int i = 0; i < count; i++)
            {
                GoalEvaluator evaluator = this._evaluators[i];
                if (evaluator is T)
                {
                    return(evaluator);
                }
            }
            return(null);
        }
示例#5
0
        public GoalEvaluator GetEvaluator(System.Type type)
        {
            int count = this._evaluators.Count;

            for (int i = 0; i < count; i++)
            {
                GoalEvaluator evaluator = this._evaluators[i];
                if (evaluator.GetType() == type)
                {
                    return(evaluator);
                }
            }
            return(null);
        }
示例#6
0
    public string ToStringEvaluator(Brain brain)
    {
        string text = string.Empty + evalFlag + "\n";
        int    i    = 0;

        for (int count = evaluators.Count; i < count; i++)
        {
            GoalEvaluator goalEvaluator = evaluators[i];
            float         num           = goalEvaluator.CalcEvaluateValue(brain);
            bool          flag          = FlagIsOn((EVAL_FLAG)(1 << i));
            string        text2         = text;
            text = text2 + string.Empty + i + ((!flag) ? "(Off)" : string.Empty) + string.Empty + goalEvaluator + ": " + num + "\n";
        }
        return(text.TrimEnd(null));
    }
示例#7
0
        public void Arbitrate()
        {
            double best = 0;

            MostDesirable = null;

            for (int i = 0; i < Evaluators.Count; i++)
            {
                double desire = Evaluators[i].CalculateDesirability(Owner);

                if (desire >= best)
                {
                    best          = desire;
                    MostDesirable = Evaluators[i];
                }
            }

            if (!System.Object.ReferenceEquals(MostDesirable, null))
            {
                MostDesirable.SetGoal(Owner);
            }
        }
        public static List <Tile> FindPath(Tile start, GoalEvaluator isGoal, PathfindingHeuristic costHeuristic)
        {
            Path_AStar resolver = new Path_AStar(World.Current, start, isGoal, costHeuristic);

            return(resolver.GetList());
        }
示例#9
0
 public Builder WithGoal(Goal goal, GoalEvaluator evaluator)
 {
     this.evaluators.Add(goal, evaluator);
     return(this);
 }
示例#10
0
 public void AddEvaluator(GoalEvaluator evaluator)
 {
     evaluator.brain = this;
     this._evaluators.Add(evaluator);
 }
示例#11
0
 public void AddEvaluator(GoalEvaluator <BaseSoldier> p)
 {
     Evaluators.Add(p);
 }
示例#12
0
 public void AddEvaluator(GoalEvaluator <NormalPeople> p)
 {
     Evaluators.Add(p);
 }
 public void AddEvaluator(GoalEvaluator <SimWood> p)
 {
     Evaluators.Add(p);
 }