AIMA.Core.Search.Uninformed.DepthLimitedSearch.recursiveDLS C# (CSharp) Метод

recursiveDLS() приватный Метод

private recursiveDLS ( Node node, Problem problem, int limit ) : List
node AIMA.Core.Search.Framework.Node
problem AIMA.Core.Search.Framework.Problem
limit int
Результат List
        private List<Action> recursiveDLS(Node node, Problem problem, int limit)
        {
            // if problem.GOAL-TEST(node.STATE) then return SOLUTION(node)
            if (SearchUtils.isGoalState(problem, node))
            {
                setPathCost(node.getPathCost());
                return SearchUtils.actionsFromNodes(node.getPathFromRoot());
            }
            else if (0 == limit)
            {
                // else if limit = 0 then return cutoff
                return cutoff();
            }
            else
            {
                // else
                // cutoff_occurred? <- false
                bool cutoff_occurred = false;
                // for each action in problem.ACTIONS(node.STATE) do
                foreach (Node child in this.expandNode(node, problem))
                {
                    // child <- CHILD-NODE(problem, node, action)
                    // result <- RECURSIVE-DLS(child, problem, limit - 1)
                    List<Action> result = recursiveDLS(child, problem, limit - 1);
                    // if result = cutoff then cutoff_occurred? <- true
                    if (isCutOff(result))
                    {
                        cutoff_occurred = true;
                    }
                    else if (!isFailure(result))
                    {
                        // else if result != failure then return result
                        return result;
                    }
                }

                // if cutoff_occurred? then return cutoff else return failure
                if (cutoff_occurred)
                {
                    return cutoff();
                }
                else
                {
                    return failure();
                }
            }
        }