private int aphaBetaPruning(S s, int a, int b, int d) {
		visited++;
        if (d==0 || this.problem.end(s)) {
			return this.problem.value(s);
		} else {
			List<S> succ = problem.getSuccessors(s);
			for (S leaf : succ) {
				if (a > b) break;
				if (s.isMax()) a = Math.max(a, aphaBetaPruning(leaf, a, b, d-1));
				else b = Math.min(b, aphaBetaPruning(leaf, a, b, d-1));
			}
			if (s.isMax()) return a;
			else return b;
		} 					
    }