public List <Node> AStar() { // Pop off lowest F int? min = OpenList.Min(n => n.F); Node current = OpenList.Where(n => n.F == min).First(); OpenList.Remove(current); // Check for goal if (current.Equals(Goal)) { ClosedList.Push(current); return(ClosedList.Reverse().ToList()); } else { //possibleMoves = GetPassibleNodes(current); OpenList = GetPassibleNodes(current); List <Node> toRemove = new List <Node>(); OpenList.ForEach(n => { if (ClosedList.Contains(n)) { toRemove.Add(n); } else { GetF(n); } }); toRemove.ForEach(n => OpenList.Remove(n)); //possibleMoves.ForEach(n => //{ // if (!ClosedList.Contains(n)) // Dont move to an already visited Node // { // GetF(n); // if (!OpenList.Contains(n)) // { // n.Parent = current; // OpenList.Add(n); // } // } //}); } ClosedList.Push(current); return(null); }