Пример #1
0
        public stepmove MinValue(position[,] s, stepmove next, double alpha, double beta, int depth)
        {
            position[,] state2 = new position[7, 6];
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    state2[i, j].pos.X    = s[i, j].pos.X;
                    state2[i, j].pos.Y    = s[i, j].pos.Y;
                    state2[i, j].color    = s[i, j].color;
                    state2[i, j].occupied = s[i, j].occupied;
                }
            }
            result(state2, next, 1);
            stepmove v;

            v.score = double.MaxValue;
            v.pos   = next.pos;
            if (cutoff(state2, depth, 1))
            {
                v.score = evaluation(state2, 1);
                return(v);
            }
            List <stepmove> actionlist = new List <stepmove>();

            Action(state2, ref actionlist);
            foreach (stepmove a in actionlist)
            {
                v.score = Math.Min(v.score, MaxValue(state2, a, alpha, beta, depth + 1).score);
                if (v.score <= alpha)
                {
                    return(v);
                }
                beta = Math.Min(beta, v.score);
            }
            return(v);
        }
Пример #2
0
 public void result(position[,] state, stepmove a,int pcolor)
 {
     state[a.pos.X, a.pos.Y].pos = a.pos;
     state[a.pos.X, a.pos.Y].occupied = true;
     state[a.pos.X, a.pos.Y].color = pcolor;
     //return state;
 }
Пример #3
0
        public void Action(position[,] state, ref List<stepmove> r)
        {
            // List<stepmove> r = new List<stepmove>();

            for (int i = 0; i < 7; i++)
            {
                for (int j = 5; j >= 0; j--)
                {
                    if (!state[i, j].occupied)
                    {
                        stepmove temp = new stepmove();
                        temp.pos = state[i, j].pos;
                        temp.score = double.MinValue;
                        r.Add(temp);
                        break;
                    }
                }
            }
               // return r;
        }
Пример #4
0
 public stepmove MinValue(position[,] s, stepmove next,double alpha, double beta, int depth)
 {
     position[,] state2 = new position[7, 6];
     for (int i = 0; i < 7; i++)
     {
         for (int j = 0; j < 6; j++)
         {
             state2[i, j].pos.X = s[i, j].pos.X;
             state2[i, j].pos.Y = s[i, j].pos.Y;
             state2[i, j].color = s[i, j].color;
             state2[i, j].occupied = s[i, j].occupied;
         }
     }
     result(state2, next, 1);
     stepmove v;
     v.score = double.MaxValue;
     v.pos = next.pos;
     if (cutoff(state2, depth, 1))
     {
         v.score = evaluation(state2, 1);
         return v;
     }
     List<stepmove> actionlist = new List<stepmove>();
     Action(state2, ref actionlist);
     foreach (stepmove a in actionlist)
     {
         v.score = Math.Min(v.score, MaxValue(state2, a, alpha, beta, depth + 1).score);
         if (v.score <= alpha)
             return v;
         beta = Math.Min(beta, v.score);
     }
     return v;
 }