private float MinValue(BooleanState state, float Alpha, float Beta, int Depth) { if (Depth == 0) { return(EvalHeuristic(state)); } List <BooleanState> Successors = state.GetSuccessors(); foreach (BooleanState s in Successors) { Beta = Math.Min(Beta, MaxValue(s, Alpha, Beta, Depth - 1)); if (Beta <= Alpha) { break; } } return(Beta); }
public float MaxValue(BooleanState state, float Alpha, float Beta, int Depth) { if (Depth == 0) { return(EvalHeuristic(state)); } List <BooleanState> Successors = state.GetSuccessors(); foreach (BooleanState s in Successors) {//Bug inside the successors list Alpha = Math.Max(Alpha, MinValue(s, Alpha, Beta, Depth - 1)); if (Depth == 4 && Alpha >= my) { Result = s; my = Alpha; } if (Beta <= Alpha) { break; } } return(Alpha); }