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