Exemplo n.º 1
0
 public GOAPPlaner(GOAPStateContext context, IGOAPCostComparer comparer)
 {
     _builder  = new GOAPPlanBuilder(context);
     _comparer = comparer;
 }
Exemplo n.º 2
0
        public static void WritePlansWithBest(List <List <IGOAPReadOnlyAction> > plans, IGOAPCostComparer comparer)
        {
            Console.WriteLine();

            var bestCost = comparer.BadCost;

            foreach (var plan in plans)
            {
                IGOAPCost fullCost = comparer.ZeroCost;

                foreach (var action in plan)
                {
                    fullCost = fullCost.GetSumWith(action.Cost);
                }

                int value = comparer.Compare(bestCost, fullCost);

                if (value < 1)
                {
                    bestCost = fullCost;
                }
            }

            foreach (var plan in plans)
            {
                IGOAPCost fullCost = comparer.ZeroCost;

                foreach (var action in plan)
                {
                    fullCost = fullCost.GetSumWith(action.Cost);
                }

                int value = comparer.Compare(bestCost, fullCost);

                if (value > 0)
                {
                    WritePlan(plan);
                }
            }

            Console.ForegroundColor = ConsoleColor.Green;
            foreach (var plan in plans)
            {
                IGOAPCost fullCost = comparer.ZeroCost;

                foreach (var action in plan)
                {
                    fullCost = fullCost.GetSumWith(action.Cost);
                }

                int value = comparer.Compare(bestCost, fullCost);

                if (value == 0)
                {
                    WritePlan(plan);
                }
            }
            Console.ResetColor();
        }