예제 #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)
                    );
            }
        }
예제 #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);
        }
예제 #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);
        }
예제 #4
0
파일: Board.cs 프로젝트: sunchun1979/weiqiz
 public BoardBase(BoardBase b) : base(b)
 {
 }
예제 #5
0
파일: Board.cs 프로젝트: sunchun1979/weiqiz
 public BoardStatus(BoardStatus bs)
 {
     Board = new BoardBase(bs.Board);
     Turn  = bs.Turn;
 }
예제 #6
0
파일: Board.cs 프로젝트: sunchun1979/weiqiz
 public BoardStatus(byte size)
 {
     Board = new BoardBase(size);
     Turn  = WColor.EMPTY;
 }