private Move StupidHeapBuild() { Debug.Log("picking one"); IDictionary <DeciderNode, Empty> nodesInTree = new Dictionary <DeciderNode, Empty>(10000); MaxHeap heap = new MaxHeap(root); Debug.Log("adding nodes to checklist"); root.AddNodesToTreeRecursivly(nodesInTree); if (root.to.Keys == null) { return(null); } Debug.Log("popping and adding to tree"); while (nodesInTree.Count < 10000 && heap.HasTop()) { DeciderNode top = (DeciderNode)heap.Pop(); top.SetMovesTo(); foreach (DeciderNode node in top.to.Values) { if (!nodesInTree.ContainsKey(node)) { heap.AddToHeap(node); nodesInTree.Add(node, new Empty()); } } } Debug.Log(heap.Count); // picking the best for the player; DeciderNode topOfHeap = (DeciderNode)heap.Pop(); while (topOfHeap.Player != root.Player && heap.HasTop()) { topOfHeap = (DeciderNode)heap.Pop(); } return(MoveForNode(topOfHeap)); }