Exemplo n.º 1
0
        private static bool captureKernel(BoardBase board, List <Tuple <byte, byte> > captureList, byte row, byte col, WColor color)
        {
            WColor flipColor = ColorUtils.Flip(color);

            if (!BoardUtil.CheckBounds(board.Size, row, col))
            {
                return(true);
            }
            else if (board[row, col] == flipColor)
            {
                return(true);
            }
            else if (board.GetMark(row, col) == Mark.MARK1)
            {
                return(true);
            }
            else if (board[row, col] == WColor.EMPTY)
            {
                return(false);
            }
            else
            {
                captureList.Add(new Tuple <byte, byte>(row, col));
                board.Mark(row, col, Mark.MARK1);
                return(
                    captureKernel(board, captureList, (byte)(row + 1), col, color) &&
                    captureKernel(board, captureList, (byte)(row - 1), col, color) &&
                    captureKernel(board, captureList, row, (byte)(col + 1), color) &&
                    captureKernel(board, captureList, row, (byte)(col - 1), color)
                    );
            }
        }
Exemplo n.º 2
0
 public bool Play(byte row, byte col)
 {
     if (!BoardUtil.CheckBounds(_size, row, col))
     {
         return(false);
     }
     if (_currentStatus.Board.Get(row, col) != WColor.EMPTY)
     {
         return(false);
     }
     else
     {
         BoardStatus temptNew = _currentStatus;
         if (!MoveUtils.Move(ref temptNew, row, col))
         {
             return(false);
         }
         if (!boardHistory.Contains(temptNew.ToString()))
         {
             boardHistory.Add(temptNew.ToString());
             _currentStatus = temptNew;
             _LatestMove    = new Tuple <byte, byte>(row, col);
             _numMoves++;
             return(true);
         }
         return(false);
     }
 }
Exemplo n.º 3
0
 private IEnumerable <Tuple <int, int> > LoopNeighbor(int i, int j, int size)
 {
     for (int ii = -1; ii <= 1; ii++)
     {
         for (int jj = -1; jj <= 1; jj++)
         {
             if (ii * jj != 0)
             {
                 if (BoardUtil.CheckBounds(size, i + ii, j + jj))
                 {
                     yield return(new Tuple <int, int>(i + ii, j + jj));
                 }
             }
         }
     }
 }