Ejemplo n.º 1
0
        public ActionType WhatResult2(TPosition Pos)
        {
            TAnalysisRes Res = new TAnalysisRes();

            TFinal Finals = new TFinal();

            foreach (TCoords C in Finals.ForWin)
            {
                Res = C.What(Pos);

                if (Res.Act == ActionType.Def)
                {
                    return(ActionType.Def);
                }
            }

            foreach (TCoords C in Finals.ForWin)
            {
                Res = C.What(Pos);

                if (Res.Act == ActionType.Win)
                {
                    return(ActionType.Win);
                }
            }

            return(ActionType.Neutral);
        }
Ejemplo n.º 2
0
        void Run()
        {
            //Base.Run(this); // Ход Машины

            string s = Pos.GetS();

            int[] As = QL.Get_As(s);

            if (As.Count() == 0)
            {
                return;
            }

            double q;

            int a = QL.Get_A(s, 0.1, out q);

            int[] ij = Pos.Get_ij(a); // !!!!!!!!!

            TPosition P = PreMove(ij[0], ij[1]);

            // int[] ix = new int[4]; /////!!!!!!!!!!!

            double r = 0;

            TAnalysis Analysis = new TAnalysis();

            ActionType Res = Analysis.WhatResult2(P);

            if (Res == ActionType.Win)
            {
                r = 10;
            }

            if (Res == ActionType.Def)
            {
                r = -10;
            }

            tb.Text = r.ToString();

            /*
             *          Result Res = P.Who(out ix[0], out ix[1], out ix[2], out ix[3]);
             *
             *
             *          if (Res == Result.X)
             *          {
             *              r = -10;
             *          }
             *
             *          if (Res == Result.O)
             *          {
             *              r = 10;
             *          }
             */

            QL.Update_Q(s, a, r, P.GetS(), 0.1, 0.9);

            Move(ij[0], ij[1]);
        }
Ejemplo n.º 3
0
        void Init()
        {
            g.Children.Clear();

            DrawPole();

            Pos = new TPosition();
            V   = 'X';

            Count++;

            tbCount.Text = Count.ToString();
        }
Ejemplo n.º 4
0
        TPosition PreMove(int i, int j)
        {
            TPosition res = Pos.Copy();

            if (res.Mark(i, j, V))
            {
                return(res);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        public TPosition Copy()
        {
            TPosition res = new TPosition();

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    res.P[i, j] = P[i, j];
                }
            }

            return(res);
        }
Ejemplo n.º 6
0
Archivo: TPole.cs Proyecto: rwsh/AI-XO
        public TPole(Canvas g, TBase Base)
        {
            this.Base = Base;

            this.g  = g;
            H       = g.Height;
            g.Width = H;

            g.Children.Clear();

            DrawPole();

            Pos = new TPosition();
            V   = 'X';
        }
Ejemplo n.º 7
0
        // } labvit

        public TAnalysisRes What(TPosition Pos)
        {
            TAnalysisRes Res = new TAnalysisRes();

            int C_X = 0;
            int C_O = 0;
            int C_  = 0;

            foreach (TCoord c in C)
            {
                if (Pos.P[c.i, c.j] == 'X')
                {
                    C_X++;
                }

                if (Pos.P[c.i, c.j] == 'O')
                {
                    C_O++;
                }

                if (Pos.P[c.i, c.j] == ' ')
                {
                    C_++;

                    Res.Act     = ActionType.Neutral;
                    Res.Coord.i = c.i;
                    Res.Coord.j = c.j;
                }
            }

            if (C_ == 1)
            {
                // if(C_X == 2)
                if (C_X == cell_count - 1) // labvit
                {
                    Res.Act = ActionType.Def;
                }

                // if(C_O == 2)
                if (C_O == cell_count - 1) // labvit
                {
                    Res.Act = ActionType.Win;
                }
            }

            return(Res);
        }
Ejemplo n.º 8
0
        public TPosition Copy()
        {
            TPosition res = new TPosition();

            // for (int i = 0; i < 3; i++)
            // {
            //     for (int j = 0; j < 3; j++)
            for (int i = 0; i < cell_count; i++)     // labvit
            {
                for (int j = 0; j < cell_count; j++) // labvit
                {
                    res.P[i, j] = P[i, j];
                }
            }

            return(res);
        }
Ejemplo n.º 9
0
        public TAnalysisRes What(TPosition Pos)
        {
            this.Pos = Pos;

            return(IsWin());
        }