Exemplo n.º 1
0
        public void Get(out RawBlackboardDecoratorsArray precondition, out RawBlackboardScoreCalculatorsArray costCalculator, out RawBlackboardEffectorsArray effect, out byte index)
        {
            var current = new RawAction(_current);

            _current += current.Size;
            index     = _currentIndex++;
            current.Break(out precondition, out costCalculator, out effect);
        }
Exemplo n.º 2
0
        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;
            }
        }