//Add method to build tree private List <EnumIA.Action> search(Node node) { List <Node> closedList = new List <Node>(); List <Node> openList = new List <Node>(); openList.Add(node); while (openList.Any()) { var curNode = selectNode(openList); openList.Remove(curNode); closedList.Add(node); if (Desire.desireReach(curNode) || curNode.Actions.Count > 9) { return(curNode.Actions); } foreach (var nNode in curNode.nextNode()) { if (!openList.Contains(nNode)) { openList.Add(nNode); } else if (nNode.Heuristic > curNode.Heuristic) { curNode = nNode; } } } return(null); }
private List <Node> search(Node curNode, int depth) { Queue <Node> file = new Queue <Node>(); List <Node> visitedNode = new List <Node>(); file.Enqueue(curNode); depth = (int)Math.Pow(depth, 6); while (depth > 0 || Desire.desireReach(curNode)) { curNode = file.Dequeue(); if (!visitedNode.Contains(curNode)) { visitedNode.Add(curNode); foreach (Node nextNode in curNode.nextNode()) { file.Enqueue(nextNode); } depth--; } } return(file.ToList()); }