protected int maxValue(GameState state, AlphaBeta ab)
{
int v = int.MIN_VALUE;
if (terminalTest(state))
{
return(computeUtility(state));
}
else
{
List <GameState> successorList = getSuccessorStates(state);
for (int i = 0; i < successorList.Count; i++)
{
GameState successor = (GameState)successorList.get(i);
int minimumValueOfSuccessor = minValue(successor, ab.copy());
if (minimumValueOfSuccessor > v)
{
v = minimumValueOfSuccessor;
state.put("next", successor);
}
if (v >= ab.beta())
{
// System.Console.WriteLine("pruning from max");
return(v);
}
ab.setAlpha(Util.max(ab.alpha(), v));
}
return(v);
}
}