예제 #1
0
        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);
        }
예제 #2
0
        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);
        }