예제 #1
0
        public void Oturn()
        {
            int x, y;

            Console.SetCursorPosition(Console.WindowWidth / 2 + 20, Console.WindowHeight / 2 - 20);
            Console.WriteLine("O turn");
            Console.SetCursorPosition(Console.WindowWidth / 2 + 20, Console.WindowHeight / 2 - 18);
            Console.WriteLine("Row Number    = ");
            x = int.Parse(Console.ReadLine());
            Console.SetCursorPosition(Console.WindowWidth / 2 + 20, Console.WindowHeight / 2 - 17);
            Console.Write("Column Number = ");
            y         = int.Parse(Console.ReadLine());
            row[x][y] = new ButtonO(x, y);
        }
예제 #2
0
 public void newBoard()
 {
     for (int i = 0; i < 8; i++)
     {
         Button[] col = new Button[8];
         for (int j = 0; j < 8; j++)
         {
             if ((i == 3 && j == 3) || (i == 4 && j == 4))
                 col[j] = new ButtonX(i, j);
             else if ((i == 3 && j == 4) || (i == 4 && j == 3))
                 col[j] = new ButtonO(i, j);
         }
         row.Add(col);
     }
 }
예제 #3
0
 public void newBoard()
 {
     for (int i = 0; i < 8; i++)
     {
         Button[] col = new Button[8];
         for (int j = 0; j < 8; j++)
         {
             if ((i == 3 && j == 3) || (i == 4 && j == 4))
             {
                 col[j] = new ButtonX(i, j);
             }
             else if ((i == 3 && j == 4) || (i == 4 && j == 3))
             {
                 col[j] = new ButtonO(i, j);
             }
         }
         row.Add(col);
     }
 }
예제 #4
0
        public Board()
        {
            Console.SetCursorPosition(Console.WindowWidth / 2 - 8, 1);
            Console.WriteLine("OTHELLO");
            Arena();
            tampilAwal();
            for (int i = 0; i < 8; i++)
            {
                Button[] col = new Button[8];
                for (int j = 0; j < 8; j++)
                {
                    if ((i == 3 && j == 3) || (i == 4 && j == 4))
                    {
                        col[j] = new ButtonX(i, j);
                    }
                    else if ((i == 3 && j == 4) || (i == 4 && j == 3))
                    {
                        col[j] = new ButtonO(i, j);
                    }
                }
                row.Add(col);
            }
            //FOR PRINT THE MAP

            /*for(int i=0;i<8;i++)
             * {
             *  foreach (Button j in row[i])
             *      {
             *          if (j is ButtonO)
             *              Console.Write("o ");
             *          else if (j is ButtonX)
             *              Console.Write("x ");
             *          else
             *              Console.Write("# ");
             *      }
             * Console.WriteLine();
             * }*/
        }
예제 #5
0
 public void ReverseXtoO(int key)
 {
     //left
     if (findleft(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int c = query[key - 1].c - 1; c >= 0; c--)
         {
             if (row[query[key - 1].r][c] is ButtonX)
             {
                 row[query[key - 1].r][c] = new ButtonO(query[key - 1].r, c);
             }
             else if (row[query[key - 1].r][c] is ButtonO)
             {
                 break;
             }
         }
     }
     //right
     if (findright(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int c = query[key - 1].c + 1; c < 8; c++)
         {
             if (row[query[key - 1].r][c] is ButtonX)
             {
                 row[query[key - 1].r][c] = new ButtonO(query[key - 1].r, c);
             }
             else if (row[query[key - 1].r][c] is ButtonO)
             {
                 break;
             }
         }
     }
     //up
     if (findup(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r - 1; r >= 0; r--)
         {
             if (row[r][query[key - 1].c] is ButtonX)
             {
                 row[r][query[key - 1].c] = new ButtonO(r, query[key - 1].c);
             }
             else if (row[r][query[key - 1].c] is ButtonO)
             {
                 break;
             }
         }
     }
     //down
     if (finddown(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r + 1; r < 8; r++)
         {
             if (row[r][query[key - 1].c] is ButtonX)
             {
                 row[r][query[key - 1].c] = new ButtonO(r, query[key - 1].c);
             }
             else if (row[r][query[key - 1].c] is ButtonO)
             {
                 break;
             }
         }
     }
     //dleftup
     if (findDleftup(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].c;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r - 1; r >= 0; r--)
         {
             j--;
             if (j < 0)
             {
                 break;
             }
             if (row[r][j] is ButtonX)
             {
                 row[r][j] = new ButtonO(r, j);
             }
             else if (row[r][j] is ButtonO)
             {
                 break;
             }
         }
     }
     //dleftdown
     if (findDleftdown(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].c;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r + 1; r < 8; r++)
         {
             j--;
             if (j < 0)
             {
                 break;
             }
             if (row[r][j] is ButtonX)
             {
                 row[r][j] = new ButtonO(r, j);
             }
             else if (row[r][j] is ButtonO)
             {
                 break;
             }
         }
     }
     //drightup
     if (findDrightup(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].r;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int c = query[key - 1].c + 1; c < 8; c++)
         {
             j--;
             if (j - 1 < 0)
             {
                 break;
             }
             if (row[j][c] is ButtonX)
             {
                 row[j][c] = new ButtonO(j, c);
             }
             else if (row[j][c] is ButtonO)
             {
                 break;
             }
         }
     }
     //drightdown
     if (findDrightdown(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].c;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r + 1; r < 8; r++)
         {
             j++;
             if (j + 1 > 7)
             {
                 break;
             }
             if (row[r][j] is ButtonX)
             {
                 row[r][j] = new ButtonO(r, j);
             }
             else if (row[r][j] is ButtonO)
             {
                 break;
             }
         }
     }
 }
예제 #6
0
 public void ReverseXtoO(int key)
 {
     //left
     if (findleft(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int c = query[key - 1].c - 1; c >= 0; c--)
         {
             if (row[query[key - 1].r][c] is ButtonX)
                 row[query[key - 1].r][c] = new ButtonO(query[key - 1].r, c);
             else if (row[query[key - 1].r][c] is ButtonO)
                 break;
         }
     }
     //right
     if (findright(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int c = query[key - 1].c + 1; c < 8; c++)
         {
             if (row[query[key - 1].r][c] is ButtonX)
                 row[query[key - 1].r][c] = new ButtonO(query[key - 1].r, c);
             else if (row[query[key - 1].r][c] is ButtonO)
                 break;
         }
     }
     //up
     if (findup(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r - 1; r >= 0; r--)
         {
             if (row[r][query[key - 1].c] is ButtonX)
                 row[r][query[key - 1].c] = new ButtonO(r, query[key - 1].c);
             else if (row[r][query[key - 1].c] is ButtonO)
                 break;
         }
     }
     //down
     if (finddown(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r + 1; r < 8; r++)
         {
             if (row[r][query[key - 1].c] is ButtonX)
                 row[r][query[key - 1].c] = new ButtonO(r, query[key - 1].c);
             else if (row[r][query[key - 1].c] is ButtonO)
                 break;
         }
     }
     //dleftup
     if (findDleftup(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].c;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r - 1; r >= 0; r--)
         {
             j--;
             if (j < 0) break;
             if (row[r][j] is ButtonX)
                 row[r][j] = new ButtonO(r, j);
             else if (row[r][j] is ButtonO)
                 break;
         }
     }
     //dleftdown
     if (findDleftdown(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].c;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r + 1; r < 8; r++)
         {
             j--;
             if (j < 0) break;
             if (row[r][j] is ButtonX)
                 row[r][j] = new ButtonO(r, j);
             else if (row[r][j] is ButtonO)
                 break;
         }
     }
     //drightup
     if (findDrightup(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].r;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int c = query[key - 1].c + 1; c < 8; c++)
         {
             j--;
             if (j - 1 < 0) break;
             if (row[j][c] is ButtonX)
                 row[j][c] = new ButtonO(j, c);
             else if (row[j][c] is ButtonO)
                 break;
         }
     }
     //drightdown
     if (findDrightdown(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].c;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r + 1; r < 8; r++)
         {
             j++;
             if (j + 1 > 7) break;
             if (row[r][j] is ButtonX)
                 row[r][j] = new ButtonO(r, j);
             else if (row[r][j] is ButtonO)
                 break;
         }
     }
 }