public GameTreeAction <A> GetBestAction(int depth) { if (depth != 0) { GameTreeAction <A> bestAction = null; var nextDepth = depth - 1; foreach (var nextAction in NodeData.GetNextActions(NodeColor)) { nextAction.score = CurrentScore + (NodeColor.IsRed ? nextAction.score : -nextAction.score); var nextNode = new GameTreeNode <D, A>(this, nextAction); var bestNextAction = nextNode.GetBestAction(nextDepth); if (TestAndUpdateThreshold(bestNextAction.score)) { bestAction = bestNextAction; if (NeedsCutTreeNode()) { break; } } } if (nodeParent == null) { return(bestAction); } if (bestAction != null) { nodeAction.score = bestAction.score; } } return(nodeAction); }
public GameTreeAction <A> GetBestAction(int depth) { var rootNote = new GameTreeNode <D, A>(rootData, rootColor); return(rootNote.GetBestAction(depth)); }