public MainPlannerJob( RawLayer layer, PlannerResult previousLayerResult, PlannerResult currentPlan, float maxFScore, RawBlackboardArray datasets, PlannerResult output) { // domain layer.Break(out _targets, out _actions); _goal = default; // layering _previousLayerResult = previousLayerResult; // previous run _currentPlan = currentPlan; // settings _maxFScore = maxFScore; // runtime data _datasets = datasets; // output _output = output; }
public void Execute() { var previousLayerResult = _previousLayerResult.ResultType; // if parent planner is uninitialized then mark self as failed if (previousLayerResult == PlannerResultType.Uninitialized) { Debug.LogError("Planner was run with the parent result still being uninitialized."); _output.ResultType = PlannerResultType.Failure; _output.Count = 0; return; } // if parent planner failed, no point in calculating anything if (previousLayerResult == PlannerResultType.Failure) { _output.ResultType = PlannerResultType.Failure; _output.Count = 0; return; } _goal = _targets[_previousLayerResult[_previousLayerResult.CurrentIndex]]; if (previousLayerResult == PlannerResultType.Unchanged && CurrentPlanIsStillValid()) { _output.Container.CopyFrom(_currentPlan.Container); _output.ResultType = PlannerResultType.Unchanged; return; } float threshold = _goal.CalculateHeuristic(_datasets[0]); float score; while ((score = PerformHeuristicEstimatedSearch(1, 0, threshold)) > 0 && score <= _maxFScore) { threshold = score; } _datasets = new RawBlackboardArray(); if (score > _maxFScore) { _output.ResultType = PlannerResultType.Failure; _output.Count = 0; } }