Пример #1
0
        public void PerformOnlyActionInPlan()
        {
            string actionName = "Build Harvester";
            var state = new State();
            state.PlanningActions.Add(new PlanningAction(actionName).Produces("Harvester"));
            var g0 = new Goal("Build Harvester").Target("Harvester", 1);

            IPlan p = new DFSPlan();
            p.Search(state, g0);

            Assert.That(p.GetPath()[0].Name, Is.EqualTo(actionName));
        }
Пример #2
0
        public void PerformOnlyActionInPlan()
        {
            string actionName = "Build Harvester";
            var    state      = new State();

            state.PlanningActions.Add(new PlanningAction(actionName).Produces("Harvester"));
            var g0 = new Goal("Build Harvester").Target("Harvester", 1);

            IPlan p = new DFSPlan();

            p.Search(state, g0);

            Assert.That(p.GetPath()[0].Name, Is.EqualTo(actionName));
        }
Пример #3
0
        public void LimitDepthFirstPlanSearch()
        {
            var state = new State();
            state.AddItem("Cash", 0);
            var action = new PlanningAction("Get Salary").Produces("Cash",100);
            state.PlanningActions.Add(action);

            var g0 = new Goal("Accumulate Cash").Target("Cash", 1000);

            IPlan p = new DFSPlan().SetMaxSearchDepth(3);
            p.Search(state, g0);

            Assert.That(p.GetPath().Count, Is.EqualTo(3));
        }
Пример #4
0
        public void DontPerformAnyActionWhenNoActionIsAvailable()
        {
            var state = new State();
            state.AddItem("Cash", 99);
            var action = new PlanningAction("Not affordable").Consumes("Cash", 100).Produces("Harvester");
            state.PlanningActions.Add(action);

            var g0 = new Goal("Build Harvester").Target("Harvester", 1);

            IPlan p = new DFSPlan();
            p.Search(state, g0);

            Assert.That(p.GetPath().ToList().Count, Is.EqualTo(0));
        }
Пример #5
0
        public void LimitDepthFirstPlanSearch()
        {
            var state = new State();

            state.AddItem("Cash", 0);
            var action = new PlanningAction("Get Salary").Produces("Cash", 100);

            state.PlanningActions.Add(action);

            var g0 = new Goal("Accumulate Cash").Target("Cash", 1000);

            IPlan p = new DFSPlan().SetMaxSearchDepth(3);

            p.Search(state, g0);

            Assert.That(p.GetPath().Count, Is.EqualTo(3));
        }
Пример #6
0
        public void DontPerformAnyActionWhenNoActionIsAvailable()
        {
            var state = new State();

            state.AddItem("Cash", 99);
            var action = new PlanningAction("Not affordable").Consumes("Cash", 100).Produces("Harvester");

            state.PlanningActions.Add(action);

            var g0 = new Goal("Build Harvester").Target("Harvester", 1);

            IPlan p = new DFSPlan();

            p.Search(state, g0);

            Assert.That(p.GetPath().ToList().Count, Is.EqualTo(0));
        }