Пример #1
0
        //Ai turn
        private void Ai()
        {
            if (!win)
            {
                Spot = ai.AICheck(Spot);
                if (turn == 'O')
                {
                    if (Spot != -1)
                    {
                        Check();
                        SplitSpot(Spot);
                        board1[x][y].Image  = O;
                        board1[x][y].Click -= Clicks[Spot];
                        board1[x][y].Refresh();
                        board1[x][y].Text = "O";
                        Board[Spot]       = 'O';
                        Spot = -1;
                        turn = 'X';
                        Check();
                    }
                    else
                    {
                        Check();
                        Spot = rand.Next(9);

                        while (Board[Spot] != ' ')
                        {
                            Spot = rand.Next(9);
                        }

                        SplitSpot(Spot);

                        board1[x][y].Image  = O;
                        board1[x][y].Click -= Clicks[Spot];
                        board1[x][y].Refresh();
                        board1[x][y].Text = "O";
                        Board[Spot]       = 'O';
                        turn = 'X';
                        Spot = -1;
                        Check();
                    }
                }
            }
            else
            {
                ScoreBoard();
            }
        }