public override GoalStatus Process()
        {
            // Remove all completed subgoals
            Subgoals.RemoveAll(g => g.GoalStatus == GoalStatus.Completed || g.GoalStatus == GoalStatus.Failed);

            // Activate goal when inactive
            if (GoalStatus == GoalStatus.Inactive)
            {
                Activate();
            }

            // Decide which atomic goal to choose or to stop
            if (Subgoals.Count == 0)
            {
                if (Entity.Hunger >= 0.8 && Entity.Sleep >= 0.5)
                {
                    Terminate();
                }
                else if (Entity.Hunger < Entity.Sleep)
                {
                    AddSubgoal(new EatGoal(Entity));
                }
                else
                {
                    AddSubgoal(new SleepGoal(Entity));
                }
            }

            Subgoals.ForEach(g => g.Process());

            return(GoalStatus);
        }
        public override GoalStatus Process()
        {
            if (GoalStatus == GoalStatus.Inactive)
            {
                Activate();
            }

            // Remove all completed subgoals
            Subgoals.RemoveAll(g => g.GoalStatus == GoalStatus.Completed || g.GoalStatus == GoalStatus.Failed);

            // If hunger or sleep is below a certain point attent to vitality
            if (!Subgoals.OfType <VitalityGoal>().Any() && GetDesirability(Entity.Hunger, Entity.Sleep) < 0.5)
            {
                AddSubgoal(new VitalityGoal(Entity));
            }

            Console.WriteLine($"Des: {GetDesirability(Entity.Hunger, Entity.Sleep)}        hung: {Entity.Hunger}, sleep: { Entity.Sleep}");

            // If the target changes follow the new target
            if (oldTarget != GameWorld.Instance.Target)
            {
                AddSubgoal(new FollowTargetGoal(Entity));
                oldTarget = GameWorld.Instance.Target;
            }

            // Process all subgoals
            Subgoals.ForEach(g => g.Process());

            return(GoalStatus);
        }
Example #3
0
        public override StatusTypes Process()
        {
            ActivateIfInactive();

            var subgoalStatus = ProcessSubgoals();

            if (subgoalStatus != StatusTypes.Completed && subgoalStatus != StatusTypes.Failed)
            {
                return(Status);
            }
            Status            = StatusTypes.Inactive;
            _bestDesirability = 0.0f;

            if (!Subgoals.IsEmpty())
            {
                Subgoals.Peek().Terminate();
            }

            return(Status);
        }
Example #4
0
        public override GoalStatus Process()
        {
            // Activate goal when inactive
            if (GoalStatus == GoalStatus.Inactive)
            {
                Activate();
            }

            // Stop condition
            if (Path.Count == 0)
            {
                Terminate();
            }

            // When the target changes the goal has failed
            if (target != GameWorld.Instance.Target)
            {
                GoalStatus = GoalStatus.Failed;
            }

            // When completed or failed return
            if (GoalStatus == GoalStatus.Completed || GoalStatus == GoalStatus.Failed)
            {
                return(GoalStatus);
            }

            // Remove all completed subgoals
            Subgoals.RemoveAll(g => g.GoalStatus == GoalStatus.Completed);

            // Add subgoal
            if (Path.Count != 0 && !Subgoals.OfType <TraverseVertexGoal>().Any())
            {
                AddSubgoal(new TraverseVertexGoal(Entity, Path.First(), Path.Count));
                Path.RemoveFirst();
            }

            // Process all subgoals
            Subgoals.ForEach(g => g.Process());

            return(GoalStatus);
        }
Example #5
0
        // public void AddGoalPursueBot(){
        //     if (!NotPresent(GoalTypes.PursueBot)) return;

        //     RemoveAllSubgoals();
        //     AddSubgoal(new PursueBot(Agent));
        // }

        public void QueueGoalMoveToPosition(Vector3 destination)
        {
            Subgoals.Enqueue(new MoveToPosition(Agent, destination));
        }
Example #6
0
 public bool NotPresent(GoalTypes goalType)
 {
     return(Subgoals.Count <= 0 || Subgoals.Peek().GoalType != goalType);
 }