Exemplo n.º 1
0
        static void PTerm(int[,] COMP, int[,] PLAYER, string s)
        {
            int x, y;

            while (s.Length <= 1 || s.Contains(' ') || (s[0] < 'A' || s[0] > 'J') || s.Length > 3 || (s.Length == 3 && (s[1] != '1' || s[2] != '0')) || (s[1] < '1' || s[1] > '9'))
            {
                s = Console.ReadLine().ToUpper();
            }
            y = Convert.ToInt32(s[0] - 'A' + 1);
            if (s.Length == 3)
            {
                x = 10;
            }
            else
            {
                x = Convert.ToInt32(s[1] - '1' + 1);
            }
            switch (COMP[x, y])
            {
            case 0: { PLAYER[x, y] = 2; break; }

            case 1:
            {
                PLAYER[x, y] = 3;
                COMP[x, y]   = 3; if (Checking.CheckingMain(COMP, x, y))
                {
                    Checking.CheckingMain(PLAYER, x, y);
                }
                break;
            }
            }
        }
Exemplo n.º 2
0
        static void CTerm(int[,] PLfield, int[,] COMPsNew, ref int x1, ref int y1)
        {
            int x = 0, y = 0;

            if (x1 == 0 & y1 == 0)
            {
                x = new Random().Next(1, 11); y = new Random().Next(1, 11);
                System.Threading.Thread.Sleep(10);
                while (COMPsNew[x, y] != 0)
                {
                    x = new Random().Next(1, 10); y = new Random().Next(1, 10); System.Threading.Thread.Sleep(10);
                }
            }
            else
            {
                if ((COMPsNew[x1 + 1, y1] == 0 || COMPsNew[x1 + 1, y1] == 2) && (COMPsNew[x1 - 1, y1] == 0 || COMPsNew[x1 - 1, y1] == 2) &&
                    (COMPsNew[x1, y1 + 1] == 0 || COMPsNew[x1, y1 + 1] == 2) && (COMPsNew[x1, y1 - 1] == 0 || COMPsNew[x1, y1 - 1] == 2))
                {
                    if (COMPsNew[x1 + 1, y1] == 0)
                    {
                        x = x1 + 1; y = y1;
                    }
                    if (COMPsNew[x1 - 1, y1] == 0)
                    {
                        x = x1 - 1; y = y1;
                    }
                    if (COMPsNew[x1, y1 + 1] == 0)
                    {
                        x = x1; y = y1 + 1;
                    }
                    if (COMPsNew[x1, y1 - 1] == 0)
                    {
                        x = x1; y = y1 - 1;
                    }
                }
                if (COMPsNew[x1 + 1, y1] == 3)
                {
                    if (COMPsNew[x1 - 1, y1] == 0)
                    {
                        x = x1 - 1; y = y1;
                    }
                    if (x1 + 2 < COMPsNew.GetLength(0) && COMPsNew[x1 + 2, y1] == 0)
                    {
                        x = x1 + 2; y = y1;
                    }
                    if (x1 + 3 < COMPsNew.GetLength(0) && COMPsNew[x1 + 3, y1] == 0 && COMPsNew[x1 + 2, y1] == 3)
                    {
                        x = x1 + 3; y = y1;
                    }
                }
                if (COMPsNew[x1 - 1, y1] == 3)
                {
                    if (COMPsNew[x1 + 1, y1] == 0)
                    {
                        x = x1 + 1; y = y1;
                    }
                    if (x1 - 2 > 0 && COMPsNew[x1 - 2, y1] == 0)
                    {
                        x = x1 - 2; y = y1;
                    }
                    if (x1 - 3 > 0 && COMPsNew[x1 - 3, y1] == 0 && COMPsNew[x1 - 2, y1] == 3)
                    {
                        x = x1 - 3; y = y1;
                    }
                }
                if (COMPsNew[x1, y1 + 1] == 3)
                {
                    if (COMPsNew[x1, y1 - 1] == 0)
                    {
                        x = x1; y = y1 - 1;
                    }
                    if (y1 + 2 < COMPsNew.GetLength(1) && COMPsNew[x1, y1 + 2] == 0)
                    {
                        x = x1; y = y1 + 2;
                    }
                    if (y1 + 3 < COMPsNew.GetLength(1) && COMPsNew[x1, y1 + 3] == 0 && COMPsNew[x1, y1 + 2] == 3)
                    {
                        x = x1; y = y1 + 3;
                    }
                }
                if (COMPsNew[x1, y1 - 1] == 3)
                {
                    if (COMPsNew[x1, y1 + 1] == 0)
                    {
                        x = x1; y = y1 + 1;
                    }
                    if (y1 - 2 > 0 && COMPsNew[x1, y1 - 2] == 0)
                    {
                        x = x1; y = y1 - 2;
                    }
                    if (y1 - 3 > 0 && COMPsNew[x1, y1 - 3] == 0 && COMPsNew[x1, y1 - 2] == 3)
                    {
                        x = x1; y = y1 - 3;
                    }
                }
                if (x == 0 || y == 0)
                {
                    x = new Random().Next(1, 10); y = new Random().Next(1, 10);
                    System.Threading.Thread.Sleep(10);
                    while (COMPsNew[x, y] != 0)
                    {
                        x = new Random().Next(1, 10); y = new Random().Next(1, 10); System.Threading.Thread.Sleep(10);
                    }
                }
            }
            switch (PLfield[x, y])
            {
            case 0: { COMPsNew[x, y] = 2; break; }

            case 1:
            {
                x1             = x; y1 = y;
                COMPsNew[x, y] = 3;
                PLfield[x, y]  = 3; if (Checking.CheckingMain(PLfield, x, y))
                {
                    Checking.CheckingMain(COMPsNew, x, y); x1 = 0; y1 = 0;
                }
                break;
            }
            }
        }