@@ -0,0 +1,1402 @@
+package main.java;%0A%0Aimport java.util.List;%0A%0Apublic class MinMaxABEngine %3CS extends AdversarySearchState, P extends AdversarySearchProblem%3CS%3E%3E extends AdversarySearchEngine%3CP,S%3E %7B%0A%0A%09public MinMaxABEngine(P p) %7B%0A%09%09problem = p;%0A%09%7D%0A%0A%09public int computeValue(S state) %7B%0A%09%09return minMaxAB(state, maxDepth,Integer.MIN_VALUE,Integer.MAX_VALUE);%0A%09%7D%0A%0A%09public S computeSuccessor(S state) %7B%0A%09%09List%3CS%3E successors = problem.getSuccessors(state);%0A%09%09S result = null;%0A%09%09int resValue = Integer.MIN_VALUE;%0A%09%09for(S succ : successors)%7B%0A%09%09%09int value = computeValue(succ);%0A%09%09%09if ( value %3E resValue)%7B%0A%09%09%09%09resValue = value;%0A%09%09%09%09result = succ;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return result;%0A%09%7D%0A%0A%09@Override%0A%09public void report() %7B%0A%09%09// TODO Auto-generated method stub%0A%09%09%0A%09%7D%0A%0A%09public int minMaxAB(S state, int depth, int alpha, int beta)%7B%0A%09%09if(problem.end(state) %7C%7C depth == 0)%7B%0A%09%09%09return problem.value(state);%0A%09%09%7Delse%7B%0A%09%09%09List%3CS%3E suc = problem.getSuccessors(state);%0A%09%09%09for (S child : suc) %7B%0A%09%09%09%09if (state.isMax())%7B%0A%09%09%09%09%09alpha = max(alpha, minMaxAB(child, depth-1, alpha, beta));%0A%09%09%09%09%7Delse%7B%0A%09%09%09%09%09beta = min(beta, minMaxAB(child, depth-1, alpha, beta));%0A%09%09%09%09%7D%0A%09%09%09%09if(alpha %3E= beta)%7B%0A%09%09%09%09%09break;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09if (state.isMax())%7B%0A%09%09%09%09return alpha;%0A%09%09%09%7Delse%7B%0A%09%09%09%09return beta;%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%09%0A%09private int min(int num1, int num2) %7B%0A%09%09return (num1 %3C num2) ? num1 : num2;%0A%09%7D%0A%0A%09private int max(int num1, int num2) %7B%0A%09%09return (num1 %3E= num2) ? num1 : num2;%0A%09%7D%0A%0A%7D

add minMaxAB search engine