Beispiel #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)
                    );
            }
        }
Beispiel #2
0
        public static bool CheckMove(BoardBase status, WColor turn, byte row, byte col)
        {
            BoardStatus toCheck = new BoardStatus(status.Size);

            toCheck.Board = new BoardBase(status);
            toCheck.Turn  = turn;
            bool ret = Move(ref toCheck, row, col);

            return(ret);
        }
Beispiel #3
0
        private static List <Tuple <byte, byte> > Capture(BoardStatus newStatus, byte row, byte col, WColor color)
        {
            var       capturedStones = new List <Tuple <byte, byte> >();
            BoardBase bbTemp         = new BoardBase(newStatus.Board);

            if (!captureKernel(bbTemp, capturedStones, row, col, color))
            {
                capturedStones.Clear();
            }
            return(capturedStones);
        }
Beispiel #4
0
 public BoardBase(BoardBase b) : base(b)
 {
 }
Beispiel #5
0
 public BoardStatus(BoardStatus bs)
 {
     Board = new BoardBase(bs.Board);
     Turn  = bs.Turn;
 }
Beispiel #6
0
 public BoardStatus(byte size)
 {
     Board = new BoardBase(size);
     Turn  = WColor.EMPTY;
 }