public GOAPPlaner(GOAPStateContext context, IGOAPCostComparer comparer) { _builder = new GOAPPlanBuilder(context); _comparer = comparer; }
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(); }