private int minValue(StateNode currentNode, int depth, int alpha, int beta) { if (currentNode.isTerminalNode()) { currentNode.setAlpha(alpha); currentNode.setBeta(beta); StateNode.win_count++; return(currentNode.getValue()); } else { currentNode.setAlpha(alpha); currentNode.setBeta(beta); currentNode.setValue(1000); foreach (StateNode child in currentNode.Children) { currentNode.setValue(Math.Min(currentNode.getValue(), maxValue(child, depth++, currentNode.getAlpha(), currentNode.getBeta()))); currentNode.setBeta(Math.Min(currentNode.getBeta(), currentNode.getValue())); if (currentNode.getBeta() <= currentNode.getAlpha()) { return(currentNode.getValue()); } } return(currentNode.getValue()); } }