public double CalculateSuggestedDailyFatIntake(IGoal currentGoal,
                                                       IRestingEnergyCalculator restingEnergyCalculator)
        {
            double suggestFatIntake = 0;

            switch (currentGoal.GoalType)
            {
            case GoalType.loseweight:
                suggestFatIntake =
                    (int)(0.35 * CalculateSuggestedDailyCalorieIntake(currentGoal, restingEnergyCalculator) / 9);
                break;

            case GoalType.maintainweight:
                suggestFatIntake =
                    (int)(0.3 * CalculateSuggestedDailyCalorieIntake(currentGoal, restingEnergyCalculator) / 9);
                break;

            case GoalType.gainweight:
                suggestFatIntake =
                    (int)(0.2 * CalculateSuggestedDailyCalorieIntake(currentGoal, restingEnergyCalculator) / 9);
                break;
            }

            return(suggestFatIntake);
        }
Example #2
0
        private void Search(State state, IGoal goal, int depth)
        {
            if (goal.Fulfillment(state) > bestscore)
            {
                bestscore = goal.Fulfillment(state);
                bestdepth = depth;
                bestActionStack = new Stack<PlanningAction>(planStack.Reverse());
                bestStateStack = new Stack<State>(stateStack.Reverse());
            }
            if (goal.Fulfillment(state) == bestscore && depth < bestdepth)
            {
                bestdepth = depth;
                bestActionStack = new Stack<PlanningAction>(planStack.Reverse());
                bestStateStack = new Stack<State>(stateStack.Reverse());
            }

            if (depth < _maxsearchdepth)
            {
                foreach (var a in state.PlanningActions.Where(l => l.CanExecute(state)))
                {
                    var migratedState = a.Migrate(state);
                    if(!stateStack.Contains(migratedState))
                    {
                        planStack.Push(a);
                        stateStack.Push(migratedState);
                        Search(migratedState, goal, depth + 1);
                        stateStack.Pop();
                        planStack.Pop();
                    }
                }
            }
        }
        public double CalculateSuggestedDailyCarbsIntake(IGoal currentGoal,
                                                         IRestingEnergyCalculator restingEnergyCalculator)
        {
            double suggestCarbsIntake = 0;

            switch (currentGoal.GoalType)
            {
            case GoalType.loseweight:
                suggestCarbsIntake =
                    0.25 * CalculateSuggestedDailyCalorieIntake(currentGoal, restingEnergyCalculator) / 4;
                break;

            case GoalType.maintainweight:
                suggestCarbsIntake =
                    0.4 * CalculateSuggestedDailyCalorieIntake(currentGoal, restingEnergyCalculator) / 4;
                break;

            case GoalType.gainweight:
                suggestCarbsIntake =
                    0.5 * CalculateSuggestedDailyCalorieIntake(currentGoal, restingEnergyCalculator) / 4;
                break;
            }

            return(suggestCarbsIntake);
        }
Example #4
0
        /// <summary>
        /// Returns if this state qualifies as a goal state.
        /// Checks that all items in the goal match the current state. If an item
        /// does not exist in the state, it expands it to contain that item's state.
        /// </summary>
        public bool IsGoalState(IGoal goal, bool returnGoal = true)
        {
            var worldGoal = goal as WorldGoal;

            DebugUtils.Assert(worldGoal != null, "Expected WorldGoal but got " + goal);
            var isGoal = true;

            foreach (var targetGoal in worldGoal)
            {
                if (targetGoal.Key == null || targetGoal.Key.ToString() == "Null" || targetGoal.Key.ToString() == "null")
                {
                    continue;
                }
                if (!ContainsKey(targetGoal.Key))
                {
                    this[targetGoal.Key] = targetGoal.Key.GetState();
                }
                var targetState = this[targetGoal.Key];
                if (!targetState.DoConditionsApply(targetGoal.Value))
                {
                    isGoal = false;
                    break;
                }
            }
            if (returnGoal)
            {
                worldGoal.ReturnSelf();
            }
            return(isGoal);
        }
Example #5
0
        public override void UpdateData()
        {
            var goals = agent.AgentGoalMgr.FindGoals();

            if (planHandler.IsComplete || cacheGoal == null || cacheGoal != goals.GoalsSortPriority())
            {
                if (goals.Count <= 0)
                {
                    LogTool.Log($"无计划制定");
                    planHandler.CurrActionHandlers.Clear();
                    planHandler.CurrActionHandlers.AddLast(agent.AgentActionMgr.GetHandler(ActionTag.Idle));
                    return;
                }

                if (planHandler.CurrGoal == null || goals.GoalsSortPriority() != planHandler.CurrGoal)
                {
                    //目标没有时候执行
                    //目标发生改变时候执行
                    planHandler.CurrGoal           = goals.GoalsSortPriority();
                    cacheGoal                      = planHandler.CurrGoal;
                    planHandler.CurrActionHandlers = planHandler.Planner.BuildPlan(planHandler.CurrGoal);
                }
                else
                {
                    LogTool.Log($"目标相同 {planHandler.CurrGoal}");
                }
            }

            agent.AgentActionMgr.ExcuteHandler(planHandler.HandlerAction());
        }
Example #6
0
 internal MailChimp(
     IAutomations automations, 
     ICampaigns campaigns, 
     IConversations conversations, 
     IEcomm ecomm, 
     IFolders folders, 
     IGallery gallery, 
     IGoal goal, 
     IHelper helper, 
     ILists lists, 
     IReports reports, 
     ITemplates templates, 
     IUsers users, 
     IVip vip)
 {
     Automations = automations;
     Campaigns = campaigns;
     Conversations = conversations;
     Ecomm = ecomm;
     Folders = folders;
     Gallery = gallery;
     Goal = goal;
     Helper = helper;
     Lists = lists;
     Reports = reports;
     Templates = templates;
     Users = users;
     Vip = vip;
 }
Example #7
0
        public RRTPlanner(
            double goalBias,
            int maximumNumberOfIterations,
            IWorldDefinition world,
            Random random,
            TimeSpan timeStep,
            IGoal goal)
        {
            if (goalBias > 0.5)
            {
                throw new ArgumentOutOfRangeException($"Goal bias must be at most 0.5 (given {goalBias}).");
            }

            this.goalBias = goalBias;
            this.maximumNumberOfIterations = maximumNumberOfIterations;
            this.vehicleModel      = world.VehicleModel;
            this.motionModel       = world.MotionModel;
            this.track             = world.Track;
            this.collisionDetector = world.CollisionDetector;
            this.random            = random;
            this.timeStep          = timeStep;
            this.goal    = goal;
            this.actions = world.Actions;

            distances = new DistanceMeasurement(track.Width, track.Height);

            ExploredStates = exploredStates;
        }
Example #8
0
        private void Search(State state, IGoal goal, int depth)
        {
            if (goal.Fulfillment(state) > bestscore)
            {
                bestscore       = goal.Fulfillment(state);
                bestdepth       = depth;
                bestActionStack = new Stack <PlanningAction>(planStack.Reverse());
                bestStateStack  = new Stack <State>(stateStack.Reverse());
            }
            if (goal.Fulfillment(state) == bestscore && depth < bestdepth)
            {
                bestdepth       = depth;
                bestActionStack = new Stack <PlanningAction>(planStack.Reverse());
                bestStateStack  = new Stack <State>(stateStack.Reverse());
            }

            if (depth < _maxsearchdepth)
            {
                foreach (var a in state.PlanningActions.Where(l => l.CanExecute(state)))
                {
                    var migratedState = a.Migrate(state);
                    if (!stateStack.Contains(migratedState))
                    {
                        planStack.Push(a);
                        stateStack.Push(migratedState);
                        Search(migratedState, goal, depth + 1);
                        stateStack.Pop();
                        planStack.Pop();
                    }
                }
            }
        }
Example #9
0
        public Plan MakePlan(
            World current, IGoal goal,
            RefreshActionsCallback actionRefresh, RefreshWorldCallback worldRefresh)
        {
            worldRefresh(current);
            PlanTree tree = new PlanTree(start: current);

            while (!tree.IsEmpty())
            {
                // Select the endpoint of the easiest plan we have
                // This is bredth-first, try "closest" for A*like
                PlanTree.Node n = tree.PopCheapestLeaf();

                if (goal.MeetsGoal(n.Expected))
                {
                    Debug.Log("Plan found!");
                    return(tree.GetPlan(n));
                }

                IList <Step> actions = actionRefresh(n.Expected);
                Debug.Log("Found " + actions.Count + " actions.");
                foreach (Step a in actions)
                {
                    tree.AddStep(n, a);
                }
            }

            Debug.Log("No plan exists!");
            return(new Plan(new List <Step>()));
        }
Example #10
0
        public static GoalDay ToDayDb(this IGoal goal)
        {
            var day = new GoalDay();

            CopyFields(goal, day);
            return(day);
        }
 public void StopTracking(IGoal goal)
 {
     if (_trackedGoals.Contains(goal))
     {
         _trackedGoals.Remove(goal);
     }
 }
Example #12
0
        public void Execute(AICharacter character, IGoal goal)
        {
            List <IInspectable> inspectables = FindInspectablesInView(character);

            inspectables.Sort(delegate(IInspectable x, IInspectable y) {
                return((character.Position - x.Position).magnitude.CompareTo((character.Position - y.Position).magnitude));
            });
            IInspectable inspectable = inspectables.Find(delegate(IInspectable obj) {
                return(!character.Knows(obj));
            });

            if (inspectable == null)
            {
                NavMeshAgent agent = character.gameObject.GetComponent <NavMeshAgent> ();
                NavMeshHit   navHit;

                do
                {
                    NavMesh.SamplePosition(UnityEngine.Random.insideUnitSphere * agent.speed + character.Position, out navHit, agent.speed, -1);
                } while (character.ExploredArea.Contains(navHit.position));

                character.AddGoal(new Goal(new List <IRequirement> ()
                {
                    new AtPosition(navHit.position)
                }, goal));
            }
            else
            {
                character.AddGoal(new Goal(new List <IRequirement> ()
                {
                    new Inspected(inspectable)
                }, goal));
            }
        }
Example #13
0
        public static GoalWeek ToWeekDb(this IGoal goal)
        {
            var week = new GoalWeek();

            CopyFields(goal, week);
            return(week);
        }
Example #14
0
        public static GoalYear ToYearDb(this IGoal goal)
        {
            var year = new GoalYear();

            CopyFields(goal, year);
            return(year);
        }
Example #15
0
        public static GoalViewModel ToViewModel(this IGoal goal)
        {
            var vm = new GoalViewModel();

            CopyFields(goal, vm);
            return(vm);
        }
Example #16
0
        public override TankUpdate Update(IGameState gameState)
        {
            // Pick a random goal to defend
            if (_goalToDefend == null && gameState.Goals.Count > 0)
            {
                var shuffledGoals = gameState.Goals.OrderBy(a => Guid.NewGuid());
                _goalToDefend = shuffledGoals.First();
            }

            TankUpdate tankUpdate = new TankUpdate();

            if (gameState.Foes.Any() && gameState.Goals.Any())
            {
                if (_targetFoe == null || _targetFoe.Health <= 0)
                {
                    // Pick a random target
                    var shuffledFoes = gameState.Foes.OrderBy(a => Guid.NewGuid());
                    _targetFoe = shuffledFoes.First();
                }

                if (_targetFoe != null)
                {
                    // Target the foe's current location
                    tankUpdate.ShotTarget = _targetFoe.Center;
                }

                // Move toward tower
                tankUpdate.MovementTarget = LocationProvider.GetLocation(_goalToDefend.X, _goalToDefend.Y);
                tankUpdate.Bullet = new Bullet { Damage = 200, Freeze = 0, SplashRange = 0 };
            }

            return tankUpdate;
        }
Example #17
0
        private TreeNode <TAction> Plan(IGoal <TGoal> goal)
        {
            var tree = new Tree <TAction>();
            //初始化树的头节点
            var topNode = CreateTopNode(tree, goal);
            //获取最优节点
            TreeNode <TAction> cheapestNode = null;
            var currentNode = topNode;

            while (!IsEnd(currentNode))
            {
                //获取所有的子行为
                var handlers = GetSubHandlers(currentNode);
                foreach (IActionHandler <TAction> handler in handlers)
                {
                    var subNode = tree.CreateNode(handler);
//                    SetNodeState(currentNode, subNode);
                    subNode.Cost       = GetCost(subNode);
                    subNode.ParentNode = currentNode;
                    cheapestNode       = GetCheapestNode(subNode, cheapestNode);
                }

                currentNode  = cheapestNode;
                cheapestNode = null;
            }

            return(currentNode);
        }
Example #18
0
 public static void ProjectNonNullGoalProperties(IGoal newGoal, IGoal previousGoal)
 {
     previousGoal.Header           = newGoal.Header ?? previousGoal.Header;
     previousGoal.Description      = newGoal.Description ?? previousGoal.Description;
     previousGoal.Parent           = newGoal.Parent ?? previousGoal.Parent;
     previousGoal.CreatedTimeStamp = newGoal.CreatedTimeStamp != new DateTimeOffset() ? newGoal.CreatedTimeStamp : previousGoal.CreatedTimeStamp;
     previousGoal.ProjectedDate    = newGoal.ProjectedDate ?? previousGoal.ProjectedDate;
 }
Example #19
0
        public void Execute(AICharacter character, IGoal goal)
        {
            NavMeshAgent agent = character.gameObject.GetComponent <NavMeshAgent> ();

            character.target.transform.position = this.position;
            character.target.SetActive(true);
            agent.SetDestination(this.position);
        }
Example #20
0
 public GoalManagerBase(IAgent <TAction, TGoal> agent)
 {
     _agent       = agent;
     CurrentGoal  = null;
     _goalsDic    = new Dictionary <TGoal, IGoal <TGoal> >();
     _activeGoals = new List <IGoal <TGoal> >();
     InitGoals();
 }
Example #21
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IGoal goal = collision.AsGoal();

        if (goal != null)
        {
            SetState(MinionState.Scoring);
        }
    }
Example #22
0
        /// <summary>
        /// サブゴールを追加
        /// </summary>
        /// <param name="subgoal"></param>
        public override void AddSubgoal(IGoal subgoal)
        {
            if (_subgoals.Contains(subgoal))
            {
                return;
            }

            _subgoals.Add(subgoal);
        }
Example #23
0
 private HUDViewController(IScore score, IMoves moves, IGoal goal, HUDView hudView)
 {
     _score   = score;
     _hudView = hudView;
     _moves   = moves;
     _goals   = goal;
     Subscribe();
     Hide();
 }
Example #24
0
 /// <summary>
 /// Return an estimated cost to reach the goal from the current state.
 /// </summary>
 public float CalculateHeuristicCost(ISearchContext agent, IGoal goal, bool useCachedValue = true)
 {
     if (useCachedValue && cachedHeuristicCost >= 0f)
     {
         return(cachedHeuristicCost);
     }
     cachedHeuristicCost = state.CalculateHeuristicCost(agent, goal);
     return(cachedHeuristicCost);
 }
        public int CheckStatus(IGoal goal)
        {
            if(_trackedGoals.Contains(goal))
            {
                return _trackedGoals[_trackedGoals.IndexOf(goal)].Calculator.GetCurrent();
            }

            return 0;
        }
Example #26
0
        private TreeNode <TAction> CreateTopNode(Tree <TAction> tree, IGoal <TGoal> goal)
        {
            TreeNode <TAction> topNode = tree.CreateTopNode();

            topNode.GoalState.Set(goal.GetEffects());
            topNode.Cost = GetCost(topNode);
            SetNodeCurrentState(topNode);
            return(topNode);
        }
Example #27
0
 public PlayerEngine(int playerIndex)
 {
     PlayerIndex    = playerIndex;
     AvailableGoals = new IGoal[]
     {
         new Attack(),
         new Defend(),
         new Possess()
     };
 }
Example #28
0
 public static void CopyFields(IGoal source, IGoal recepient)
 {
     recepient.Id               = source.Id;
     recepient.OwnerId          = source.OwnerId;
     recepient.Header           = source.Header;
     recepient.Parent           = source.Parent;
     recepient.Description      = source.Description;
     recepient.CreatedTimeStamp = source.CreatedTimeStamp;
     recepient.ProjectedDate    = source.ProjectedDate;
 }
Example #29
0
        public void PopulatePlan(IPlan <TState, TAction> plan, TState state, IGoal <TState, TAction> goal)
        {
            // Get converted plan
            var planConverted = (Plan)plan;

            // Reset plan
            _ResetPlan(planConverted);
            // Populate plan
            _explorer.PopulatePlan(planConverted, state, goal);
        }
Example #30
0
        public List <ValidationResult> ValidateResource(IGoal resource, bool validateModelForPost)
        {
            var context = new ValidationContext(resource, null, null);
            var results = new List <ValidationResult>();

            Validator.TryValidateObject(resource, context, results, true);
            ValidateGoalRules(resource, results, validateModelForPost);

            return(results);
        }
Example #31
0
    void Awake()
    {
        this.TopGoal    = transform.Find("GoalTop").GetComponentStrict <Goal>();
        this.BottomGoal = transform.Find("GoalBottom").GetComponentStrict <Goal>();

        var spawnTransform = transform.Find("SpawnPositions");

        this.OrbSpawn        = spawnTransform.Find("OrbSpawn").transform.position;
        this.TopHeroSpawn    = spawnTransform.Find("TopHeroSpawn").transform.position;
        this.BottomHeroSpawn = spawnTransform.Find("BottomHeroSpawn").transform.position;
    }
Example #32
0
        public Plan(IGoal goal, 
            IBrain brain)
        {
            this.Goal = goal;
            this.brain = brain;

            CurrentTask = new BaseTask();
            TaskQueue = new Queue<ITask>();

            IsActive = false;
        }
Example #33
0
        public VehicleState RandomSampleOfFreeRegion(IGoal goal)
        {
            var freePosition = random.NextDouble() > goalBias
                ? goal.Position
                : randomFreePosition();

            return(new VehicleState(
                       freePosition,
                       headingAngle: random.NextDoubleBetween(0, 2 * PI),
                       angularVelocity: random.NextDoubleBetween(-vehicleModel.MaxSteeringAngle, vehicleModel.MaxSteeringAngle),
                       speed: random.NextDoubleBetween(vehicleModel.MinSpeed, vehicleModel.MaxSpeed)));
        }
Example #34
0
 //更新CurrentGoal对象
 private void UpdateCurrentGoal()
 {
     CurrentGoal = FindGoal();
     if (CurrentGoal != null)
     {
         DebugMsg.Log("CurrentGoal:" + CurrentGoal.Label.ToString());
     }
     else
     {
         DebugMsg.Log("CurrentGoal is null");
     }
 }
Example #35
0
 private void _SetGoal()
 {
     // Check if laser pointer is on and position exists
     if (_owner.LaserPointer.On && _owner.LaserPointer.Position.HasValue)
     {
         // Set goal
         _goal = _goalGetLaserPoint;
     }
     else
     {
         // Set goal
         _goal = _goalHangOut;
     }
 }
Example #36
0
        public void IndexResolutions(IGoal goal)
        {
            goal.Requirements.ForEach(delegate(IRequirement requirement) {
                List <ITask> tasks = taskManager.Solve(requirement);
                if (tasks.Count == 0)
                {
                    Debug.Log("Teach me how to resolve " + requirement.GetType().Name);
                }

                tasks.ForEach(delegate(ITask task) {
                    resolutions.Add(new Resolution(goal, requirement, task));
                });
            });
        }
Example #37
0
        public void PopulatePanel(UIComponent parent, int pos, IGoal goal)
        {
            m_label = this.AddUIComponent<UILabel> ();
            m_passLabel = this.AddUIComponent<UILabel> ();
            m_failLabel = this.AddUIComponent<UILabel> ();
            m_barBackground = this.AddUIComponent<UISprite> ();
            m_bar = this.AddUIComponent<UISprite> ();

            this.m_goal = goal;

            this.backgroundSprite = "GenericPanel";
            this.color = new Color32(164,164,164,255);
            this.size = new Vector2(WIDTH, HEIGHT);

            this.transform.parent = parent.transform;
            this.transform.localPosition = Vector3.zero;
            this.relativePosition = new Vector3 (SPACING, ChallengePanel.HEAD + SPACING + pos * (HEIGHT + SPACING));

            //label
            m_label.text = m_goal.Name;
            m_label.relativePosition = new Vector3 (this.width/2 - m_label.width/2, SPACING);
            //goal
            m_passLabel.text = m_goal.PassValue;
            m_passLabel.textAlignment = UIHorizontalAlignment.Right;
            m_passLabel.relativePosition = new Vector3 (this.width - m_passLabel.width - SPACING,SPACING);

            m_failLabel.text = m_goal.FailValue;
            m_failLabel.textAlignment = UIHorizontalAlignment.Right;
            m_failLabel.relativePosition = new Vector3 (SPACING,SPACING);

            //bar
            m_barBackground.spriteName = "GenericPanel";
            m_barBackground.color = new Color32 (64, 64, 64, 255);
            m_barBackground.size = new Vector2 (BAR_WIDTH, BAR_HEIGHT);
            m_barBackground.relativePosition = new Vector2 (this.width / 2 - m_barBackground.width / 2, this.height - m_barBackground.height - 10f);

            m_bar.spriteName = "GenericPanel";

            if (m_goal.GoalType == GoalType.MINIMISE) {
                Debug.PrintMessage ("Color changed");
                m_bar.color = new Color32 (255, 255, 0, 255);
            } else {
                m_bar.color = Color.green;
            }
            m_bar.size = m_barBackground.size;
            m_bar.relativePosition = m_barBackground.relativePosition;

            if (m_goal.HasAlreadyPassed) {
                Debug.PrintMessage ("Already Passed");
                this.m_bar.color = Color.cyan;
                this.m_barBackground.color = Color.cyan;
                this.color = new Color32 (0, 128, 128, 255);
            } else if (m_goal.HasAlreadyFailed) {
                Debug.PrintMessage ("Already Failed");
                this.m_bar.color = Color.red;
                this.m_barBackground.color = Color.red;
                this.color = new Color32 (128, 0, 0, 255);
            } else {

                Debug.PrintMessage ("Attaching Pass/Fail events");
                this.m_goal.OnPassed += () => {
                    this.m_bar.color = Color.cyan;
                    this.m_barBackground.color = Color.cyan;
                    this.color = new Color32 (0, 128, 128, 255);
                };
                this.m_goal.OnFailed += () => {
                    this.m_bar.color = Color.red;
                    this.m_barBackground.color = Color.red;
                    this.color = new Color32 (128, 0, 0, 255);
                };
                this.m_goal.OnUpdate += () => {
                    this.m_bar.transform.localScale = new Vector3 (this.m_goal.GetProportion (), 1, 1);
                };
            }
        }
Example #38
0
 public void AddGoal(IGoal goal)
 {
     _goals.Add(goal);
 }
Example #39
0
 public void Search(State state, IGoal goal)
 {
     Search(state, goal, 0);
 }
 public void Track(IGoal goal)
 {
     _trackedGoals.Add(goal);
 }
Example #41
0
 public Level(float speed, LevelManager manager)
 {
     this.activeGoals = new List<IGoal>(20);
     this.speed = speed;
     this.goalFrequency = new TimeSpan(0,0,30);
     this.queuedGoals = new Queue<IGoal>(20);
     this.originalGoals = new Queue<IGoal>(20);
     this.levelDuration = new TimeSpan(0, 3, 31);
     this.manager = manager;
     this.startingGoal = null;
     this.goalRewardTime = new TimeSpan(0, 0, 30);
     this.is1337 = false;
 }
 public string GoalsToString(IGoal[] goals)
 {
     string output = "";
     foreach (IGoal goal in goals) {
         output += "\n    ";
         if (goal.GoalType == GoalType.MAXIMISE) {
             if (goal.PassOnce && goal.FailOnce) {
                 output += "Get your " + goal.Name + " to " + goal.PassValue + " once without ever dropping below " + goal.FailValue;
             } else if (goal.PassOnce) {
                 output += "Get your " + goal.Name + " to " + goal.PassValue + " just once";
             } else if (goal.FailOnce) {
                 output += "Get your " + goal.Name + " to " + goal.PassValue + " while staying above " + goal.FailValue + " at all times";
             } else {
                 output += "Get your " + goal.Name + " to " + goal.PassValue;
             }
         } else if (goal.GoalType == GoalType.MINIMISE) {
             if (goal.PassOnce && goal.FailOnce) {
                 output += "Get your " + goal.Name + " to " + goal.PassValue + " once without ever going above " + goal.FailValue;
             } else if (goal.PassOnce) {
                 output += "Get your " + goal.Name + " to " + goal.PassValue + " just once";
             } else if (goal.FailOnce) {
                 output += "Get your " + goal.Name + " to " + goal.PassValue + " while staying below " + goal.FailValue + " at all times";
             } else {
                 output += "Get your " + goal.Name + " to " + goal.PassValue;
             }
         }
     }
     return output;
 }
Example #43
0
 public void AddStartGoal(IGoal goal)
 {
     goal.GoalBox = Shorewood.goalRenderer.GetGoalBox();
     this.startingGoal = goal;
     //originalGoals.Enqueue(goal);
     //Shorewood.gameplayTimer.AddEvent(goal.GoalStartTime, new IETGames.Shorewood.Utilities.OnTime(manager.GetNextGoal), goal);
 }
Example #44
0
	/// <summary>
	/// Writes the static header for problem files to the stream
	/// </summary>
	/// <param name="its_stream">The given stream to write to.</param>
	private static void Problem_Writing_Goal(StreamWriter its_stream, IGoal[] its_goal)
	{
		its_stream.WriteLine("\t(:goal");
		its_stream.WriteLine("\t\t(and");

		//This will probably hold a list of conditions
		foreach (IGoal rep_goal in its_goal)
		{
			its_stream.WriteLine("\t\t\t(or");
			foreach (string rep_line in rep_goal.Write_Goal())
			{
				its_stream.WriteLine("\t\t\t\t(" + rep_line + ")");
			}
			its_stream.WriteLine("\t\t\t)");
		}


		its_stream.WriteLine("\t\t\t)");

		its_stream.WriteLine("\t\t)");
		its_stream.WriteLine("");

		if (self.my_optimise)
			its_stream.WriteLine("\t\t(:metric minimize (labourCost))");

		its_stream.WriteLine("");

	}
Example #45
0
 public static GoalProgressPanel CreateProgressPanel(UIComponent parent, int pos, IGoal goal)
 {
     GoalProgressPanel progressPanel = parent.AddUIComponent<GoalProgressPanel> ();
     progressPanel.Start ();
     progressPanel.PopulatePanel (parent, pos, goal);
     return progressPanel;
 }
Example #46
0
 public void UpdateGoal(IGoal goal, int Y)
 {
     Rectangle paddedBounds = bounds;
     paddedBounds.Inflate(-padding, 0);
     goalText.Remove(0, goalText.Length);
     WordWrapper.WrapWord(goal.GoalText, goalText, Shorewood.fonts[FontTypes.GoalFont], paddedBounds, 1);
     Vector2 stringBounds = Shorewood.fonts[FontTypes.GoalFont].MeasureString(goalText);
     drawBounds = new Rectangle(paddedBounds.X, Y, (int)(paddedBounds.Width), (int)(stringBounds.Y));
     completedBounds = new Rectangle(drawBounds.X, Y, (int)(drawBounds.Width * goal.GoalStatus), drawBounds.Height);
     overlayBounds = drawBounds;
     overlayBounds.Inflate(15, 9);
     boxPosition = new Vector2(drawBounds.X, drawBounds.Y);
 }
Example #47
0
 public Domain AssignGoal(IGoal goal)
 {
     Goal = goal;
     return this;
 }
Example #48
0
 public IGoal Add(IGoal goal)
 {
     _Goals.Add(goal);
     return goal;
 }
Example #49
0
 public IGoal Remove(IGoal goal)
 {
     _Goals.Remove(goal);
     return goal;
 }
Example #50
0
	/// <summary>
	///  Generates a PDDL problem to be solved
	///  It adds together several splits between the phases of writing a problem and
	/// combines them into a string to save as a separate file.
	/// </summary>
	public static void Write_Problem(string its_file, Resources its_resources, Person[] its_scoped_people, Building[] its_scoped_buildings, IGoal[] its_goal)
	{
		//using (StreamWriter quick_writer = File.CreateText(Application.dataPath + "/Resources/" + its_file + "-problem.pddl"))
		using (StreamWriter quick_writer = File.CreateText(Application.dataPath + "/PDDL/Metric-FF/" + its_file + "-problem.pddl"))
		{
			Problem_Writing_Intro(quick_writer, its_file, "prob1");
			Problem_Writing_Objects(quick_writer, its_scoped_people, its_scoped_buildings);
			Problem_Writing_Initialising(quick_writer, its_resources, its_scoped_people, its_scoped_buildings);
			Problem_Writing_Goal(quick_writer, its_goal);
			Problem_Writing_Outro(quick_writer);

			Debug.Log ("File " + Application.dataPath + "/Resources/" + its_file + ".pddl" + " created");
		}
	}