public List <NodeTree> FirstSearch(NodeTree root, int[,] goal) { List <NodeTree> pathSolution = new List <NodeTree>(); List <NodeTree> openList = new List <NodeTree>(); List <NodeTree> closeList = new List <NodeTree>(); bool goalFound = false; openList.Add(root); while (openList.Count > 0 && !goalFound) { NodeTree currentNode = openList[0]; closeList.Add(currentNode); openList.RemoveAt(0); currentNode.SideMove(); for (int i = 0; i < currentNode.children.Count; i++) { NodeTree currentChild = currentNode.children[i]; if (currentChild.IsTheGoal(goal)) { goalFound = true; TracePath(pathSolution, currentChild); } if (!Contains(openList, currentChild) && !Contains(closeList, currentChild)) { openList.Add(currentChild); } } } return(pathSolution); }