private void CreateUtilityCurves() { // Weights and Points List <float> weights = new List <float>(); weights.Add(0.6f); weights.Add(0.4f); List <Point2D> points = new List <Point2D>(); points.Add(new Point2D(0, 1)); points.Add(new Point2D(0.2f, 0.5f)); points.Add(new Point2D(0.4f, 0.1f)); points.Add(new Point2D(0.6f, 0.4f)); points.Add(new Point2D(0.8f, 0.2f)); points.Add(new Point2D(1, 0)); // Leaf Factors Factor pizzasVariable = new LeafVariable(() => pizzasCreated, 0, 10); Factor pepperoniVariable = new LeafVariable(() => pepperoniCreated, 0, 4); List <Factor> leafs = new List <Factor>(); leafs.Add(pizzasVariable); leafs.Add(pepperoniVariable); // Other Factors Factor pepperoniSum = new WeightedSumFusion(leafs, weights); Factor vegetarianLinear = new LinearPartsCurve(pizzasVariable, points); Factor hawaiianExp = new ExpCurve(pizzasVariable, 0.7f); // Actions utilityCurves.CreateUtilityAction("exit_ac1", pepperoniSum, () => { CreateRecipe(1); }, IsRecipeCreated, behaviourTree); utilityCurves.CreateUtilityAction("exit_ac2", vegetarianLinear, () => { CreateRecipe(2); }, IsRecipeCreated, behaviourTree); utilityCurves.CreateUtilityAction("exit_ac3", hawaiianExp, () => { CreateRecipe(3); }, IsRecipeCreated, behaviourTree); lookRecipe = behaviourTree.CreateSubBehaviour("Sub-Utility", utilityCurves); }
private static void CreateSubmachine() { //FACTORS // Leafs positionVariable1 = new LeafVariable(() => p2.position[0], 10.0f, 0.0f); positionVariable2 = new LeafVariable(() => p3.position[0], 10.0f, 0.0f); //ACTIONS // Basic actions Action sub1 = new Action(() => { Console.WriteLine("[BUCKET_1] Bucket. Acción 1"); Console.WriteLine("--------------------------------"); }); Action sub2 = new Action(() => { Console.WriteLine("[BUCKET_2] Bucket. Acción 2."); Console.WriteLine("--------------------------------"); p.life++; }); // Utility Actions subUtilMachine.CreateUtilityAction("bucket_1", sub1, positionVariable1); subUtilMachine.CreateUtilityAction("bucket_2", sub2, positionVariable2); }
private static void CreateMainMachine() { //FACTORS // Leafs lifeVariable1 = new LeafVariable(() => p.life, 10.0f, 0.0f); lifeVariable2 = new LeafVariable(() => p1.life, 10.0f, 0.0f); //ACTIONS //Basic actions Action a1 = new Action(() => { Console.WriteLine("[BASICO1] Se ha entrado al estado básico 1."); Console.WriteLine("--------------------------------"); }); //Utility Actions utilEngine.CreateUtilityAction("basico1", a1, lifeVariable1); utilEngine.CreateSubBehaviour("subBucket", lifeVariable2, subUtilMachine); }