Example #1
0
        protected virtual void ProcessChildNode(NodeRecord bestNode, NavigationGraphEdge connectionEdge)
        {
            //this is where you process a child node
            var childNode = GenerateChildNodeRecord(bestNode, connectionEdge);

            //Get the cost estimate for the end node
            NavigationGraphNode endNode = connectionEdge.ToNode;
            float endNodeCost           = bestNode.gValue + connectionEdge.Cost;

            //If the node is closed we may have to skip, or remove it from the close list.
            if (Closed.contains(endNode))
            {
                NodeRecord endNodeRecord = Closed.find(endNode);                  //should find this in the closed list
                if (endNodeRecord.gValue <= endNodeCost)
                {
                    continue;
                }

                Closed.Remove(endNodeRecord);
                float endNodeHeuristic = endNodeRecord.fValue - endNodeRecord.gValue;
            }
            else if (Open.contains(endNode))
            {
                NodeRecord endNodeRecord = Open.find(endNode);
                if (endNodeRecord.gValue <= endNodeCost)
                {
                    continue;
                }

                float endNodeHeuristic = endNodeRecord.fValue - endNodeRecord.gValue;
            }
            else
            {
                NodeRecord endNodeRecord = new NodeRecord();
                endNodeRecord.node = endNode;
                var endNodeHeuristic = this.Heuristic.H(endNode, GoalNode);
                endNodeRecord.gValue = endNodeCost;
                endNodeRecord.parent = bestNode;
                endNodeRecord.fValue = endNodeCost + endNodeHeuristic;
                if (!Open.contains(endNode))
                {
                    Open.Add(endNodeRecord);
                }
            }
        }