Esempio n. 1
0
        public void DecideGoalBehavior()
        {
            lastBehaviorDecision = GameTimer.Instance.GetFrameTimestamp();
            IReadonlyListX <DecisionContext> goalContexts = activeGoal.GetExecutionContexts(entity);
            float maxScore = float.MinValue;

            activeContext  = null;
            activeBehavior = null;
            for (int i = 0; i < behaviors.Count; i++)
            {
                AIBehavior behavior = behaviors[i];
                if (!behavior.CanSatisfyGoalType(activeGoal.goalType))
                {
                    //    continue;
                }
                DecisionContext context;
                float           score = AIUtil.Score(goalContexts, behavior.considerations, maxScore, out context);
                if (score > maxScore)
                {
                    maxScore       = score;
                    activeBehavior = behavior;
                    activeContext  = context;
                }
            }
        }
Esempio n. 2
0
        public void DecideGoal()
        {
            lastGoalDecision = GameTimer.Instance.GetFrameTimestamp();
            float maxScore = float.MinValue;

            activeGoal = null;
            for (int i = 0; i < goals.Count; i++)
            {
                Goal goal = goals[i];
                if ((behaviorCompatibiltyFlags & (int)goal.goalType) == 0)
                {
                    //  continue;
                }
                DecisionContext unused_bestContext;
                IReadonlyListX <DecisionContext> contexts = goal.GetEvaluationContexts(entity);
                float score = AIUtil.Score(contexts, goal.considerations, maxScore, out unused_bestContext);
                // todo personality skew the score
                if (score > maxScore)
                {
                    maxScore   = score;
                    activeGoal = goal;
                }
            }
        }