Ejemplo n.º 1
0
        public async Task CookScenario()
        {
            var pool      = CreateResourcePool();
            var provider  = new WorldStateProvider();
            var planner   = PlannerFactory.CreatePlanner();
            var actionSet = new ActionSet(GetDomainActions(pool, provider));

            var ingredients = new[] { Ingredient.CookedPatty, Ingredient.Bread, Ingredient.Cheese };

            var tasks           = new List <Task>();
            var executedActions = new List <string>();

            foreach (var ingredient in ingredients)
            {
                var goalState = DomainState.Empty.Set(ingredient + "Delivered", true);
                var result    = planner.GetPlan(provider.GetCurrentState(null), goalState, actionSet);
                Assert.True(result.Success);

                tasks.Add(RunPlan(result.Plan, executedActions));
            }

            await Task.WhenAll(tasks);

            Assert.NotEmpty(executedActions);
            Assert.Equal("Starting: Pick Up RawPatty", executedActions.First());
        }
Ejemplo n.º 2
0
        private static List <CookActionBase> GetDomainActions(ResourcePool <Cook> pool, WorldStateProvider provider)
        {
            var actions = new List <CookActionBase>
            {
                new PickUpIngredientAction(Ingredient.Bread),
                new PickUpIngredientAction(Ingredient.Tomato),
                new PickUpIngredientAction(Ingredient.Cheese),
                new PickUpIngredientAction(Ingredient.RawPatty),
                new CookPattyAction(),
                new DeliverIngredientAction(Ingredient.Bread),
                new DeliverIngredientAction(Ingredient.Tomato),
                new DeliverIngredientAction(Ingredient.Cheese),
                new DeliverIngredientAction(Ingredient.CookedPatty),
            };

            actions.ForEach(a => a.Initialize(pool, provider));

            return(actions);
        }