protected int maxValue(GameState state, AlphaBeta ab) { int v = int.MinValue; if (terminalTest(state)) { return(computeUtility(state)); } else { ArrayList successorList = getSuccessorStates(state); for (int i = 0; i < successorList.Count; i++) { GameState successor = (GameState)successorList[i]; int minimumValueOfSuccessor = minValue(successor, ab.copy()); if (minimumValueOfSuccessor > v) { v = minimumValueOfSuccessor; state.put("next", successor); } if (v >= ab.beta()) { //System.out.println("pruning from max"); return(v); } //ab.setAlpha(Util.max(ab.alpha(), v)); ab.setAlpha(System.Math.Max(ab.alpha(), v)); } return(v); } }
public override int getAlphaBetaValue(GameState state) { if (getPlayerToMove(state).ToUpper().Equals("X")) { AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue); int max = maxValue(state, initial); return(max); } else { //invert? AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue); return(minValue(state, initial)); } }
public override int getAlphaBetaValue(GameState state) { if (getPlayerToMove(state).ToUpper().Equals("X")) { AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue); int max = maxValue(state, initial); return max; } else { //invert? AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue); return minValue(state, initial); } }
protected int maxValue(GameState state, AlphaBeta ab) { int v = int.MinValue; if (terminalTest(state)) { return computeUtility(state); } else { ArrayList successorList = getSuccessorStates(state); for (int i = 0; i < successorList.Count; i++) { GameState successor = (GameState) successorList[i]; int minimumValueOfSuccessor = minValue(successor, ab.copy()); if (minimumValueOfSuccessor > v) { v = minimumValueOfSuccessor; state.put("next", successor); } if (v >= ab.beta()) { //System.out.println("pruning from max"); return v; } //ab.setAlpha(Util.max(ab.alpha(), v)); ab.setAlpha(System.Math.Max(ab.alpha(),v)); } return v; } }
public override int getAlphaBetaValue(GameState state) { this.computeUtilityCallsThisMove = 0; if (getPlayerToMove(state).ToUpper().Equals("W")) { AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue); int max = maxValue(state, initial); return max; } else { //invert? AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue); return minValue(state, initial); } }