示例#1
0
        public static void Main()
        {
            Board       b     = new Board();
            List <Move> moves = b.getValidMoves(true);

            for (int i = 1; i < 3; i++)
            {
                b = b.playMove(moves [i]);
                printBoard(b);
                moves = b.getValidMoves(true);
            }

            moves = b.getValidMoves(false);
            b     = b.playMove(moves [2]);
            printBoard(b);

            moves = b.getValidMoves(true);
            b     = b.playMove(moves [4]);
            printBoard(b);
        }
示例#2
0
        public static BoardStatus getGameState(Board currentBoard, bool white)
        {
            List <Move> validMoves = currentBoard.getValidMoves(white);

            if (validMoves.Count != 0)
            {
                return(BoardStatus.normal);
            }

            if (white)
            {
                return(currentBoard.whiteInCheck ? BoardStatus.checkmate : BoardStatus.draw);
            }
            else
            {
                return(currentBoard.blackInCheck ? BoardStatus.checkmate : BoardStatus.draw);
            }
        }
示例#3
0
        public static Move isValidMove(Board currentBoard, bool white, int[] start, int[] target)
        {
            List <Move> validMoves = currentBoard.getValidMoves(white);

            return(validMoves.Find(x => (comparePos(x.start, start) && comparePos(x.target, target))));
        }