Esempio n. 1
0
        public void setNumber(int x, int y, int num)
        {
            int      row    = (int)Math.Floor((double)y / 3);
            int      col    = (int)Math.Floor((double)x / 3);
            BoardBox bb     = board[col, row];
            int      minorX = x - (col * 3);
            int      minorY = y - (row * 3);

            bb.setNumber(minorX, minorY, num);
        }
Esempio n. 2
0
 public void whipeBoard()
 {
     for (int x = 0; x < 3; x += 1)
     {
         for (int y = 0; y < 3; y += 1)
         {
             board[x, y] = new BoardBox();
         }
     }
 }
Esempio n. 3
0
        public int getNumber(int x, int y)
        {
            int      row    = (int)Math.Floor((double)y / 3);
            int      col    = (int)Math.Floor((double)x / 3);
            BoardBox bb     = board[col, row];
            int      minorX = x - (col * 3);
            int      minorY = y - (row * 3);

            return(bb.getNumber(minorX, minorY));
        }
Esempio n. 4
0
        public bool canPlaceAtSubGrid(int subX, int subY, int relX, int relY, int num)
        {
            BoardBox subGrid  = board[subX, subY];
            int      checkNum = subGrid.getNumber(relX, relY);

            if (checkNum == 0)
            {
                bool numExists = false;
                for (int x = 0; x < 3; x += 1)
                {
                    for (int y = 0; y < 3; y += 1)
                    {
                        if ((x == relX) && (y == relY))
                        {
                            continue;
                        }
                        checkNum = subGrid.getNumber(x, y);
                        if (checkNum == num)
                        {
                            numExists = true;
                            break;
                        }
                    }
                    if (numExists)
                    {
                        break;
                    }
                }
                if (!numExists)
                {
                    // winner!
                    return(true);
                }
            }
            return(false);
        }