//this method should return true if the Search process finished (i.e either because it found a solution or because there was no solution //it should return false if the search process didn't finish yet //when returning true, the solution parameter should be set to null if there is no solution. Otherwise it must contain the found solution //if the parameter returnPartialSolution is true, then the user wants to have a partial path to the best node so far even when the search has not finished searching public bool Search(out Path solution, bool returnPartialSolution = false) { //to determine the connections of the selected nodeRecord you need to look at the NavigationGraphNode' EdgeOut list //something like this //var outConnections = bestNode.node.OutEdgeCount; //for (int i = 0; i < outConnections; i++) //{ //this.ProcessChildNode(bestNode, bestNode.node.EdgeOut(i)); //Iterate through processing each node NodeRecord current; while (Open.Count() > 0) { //Find the smallest element in the open list, using the estimatedTotalCost() current = Open.GetBestAndRemove(); //If the current node is the goal, terminate if (current.Equals(GoalNode)) { break; } //Otherwise get the outgoing connections var outConnections = current.node.OutEdgeCount; for (int i = 0; i < outConnections; i++) { this.ProcessChildNode(current, current.node.EdgeOut(i)); } Open.Remove(current); Closed.Add(current); } if (current.node != GoalNode) { solution = null; return(true); } else { Path path = new Path(); var nodes = path.PathNodes; var positions = path.PathPositions; while (current.node != StartNode) { nodes += current.parent; current = current.parent.node; } nodes.Reverse(); positions.Reverse(); solution = path; return(true); } }