Exemple #1
0
        private static List <ColoredBitBoard> GeneratePseudoLegalNonSlidingMoves(ChessBoard inputChessBoard, ChessPieceColors color, EmptyBitBoard blackPieces, EmptyBitBoard whitePieces, EmptyBitBoard allPieces)
        {
            List <ColoredBitBoard> result = new List <ColoredBitBoard>();

            result.AddRange(PawnMoveGen.PawnBitBoardResults(inputChessBoard, color, blackPieces, whitePieces, allPieces));
            result.AddRange(KingMoveGen.KingBitBoardResults(inputChessBoard, color, blackPieces, whitePieces, allPieces));
            result.AddRange(KnightMoveGen.KnightBitBoardResults(inputChessBoard, color, blackPieces, whitePieces, allPieces));
            return(result);
        }
Exemple #2
0
        private static bool isEnemyKingAttackable(ChessBoard cb, ColoredBitBoard legalMove, ChessPieceColors color)
        {
            List <ColoredBitBoard> legalMoves  = new List <ColoredBitBoard>();
            EmptyBitBoard          blackPieces = new EmptyBitBoard();
            EmptyBitBoard          whitePieces = new EmptyBitBoard();
            EmptyBitBoard          allPieces   = new EmptyBitBoard();

            cb.Update(legalMove);

            blackPieces = MoveGenUtils.SetBlackBoard(cb);
            whitePieces = MoveGenUtils.SetWhiteBoard(cb);
            allPieces   = MoveGenUtils.SetWholeBoard(cb);

            if (legalMove is PawnBitBoard)
            {
                legalMoves.AddRange(PawnMoveGen.PawnBitBoardResults(cb, color, blackPieces, whitePieces, allPieces));
            }
            else if (legalMove is BishopBitBoard)
            {
                legalMoves.AddRange(BishopMoveGen.BishopBitBoardResults(cb, color, blackPieces, whitePieces, allPieces));
            }
            else if (legalMove is KingBitBoard)
            {
                legalMoves.AddRange(KingMoveGen.KingBitBoardResults(cb, color, blackPieces, whitePieces, allPieces));
            }
            else if (legalMove is KnightBitBoard)
            {
                legalMoves.AddRange(KnightMoveGen.KnightBitBoardResults(cb, color, blackPieces, whitePieces, allPieces));
            }
            else if (legalMove is QueenBitBoard)
            {
                legalMoves.AddRange(QueenMoveGen.QueenBitBoardResults(cb, color, blackPieces, whitePieces, allPieces));
            }
            else if (legalMove is RookBitBoard)
            {
                legalMoves.AddRange(RookMoveGen.RookBitBoardResults(cb, color, blackPieces, whitePieces, allPieces));
            }

            foreach (ColoredBitBoard cbb in legalMoves)
            {
                if (color == ChessPieceColors.White && (cb.BlackKing.Bits & cbb.Bits) != 0)
                {
                    cb.Undo();
                    return(true);
                }
                else if (color == ChessPieceColors.Black && (cb.WhiteKing.Bits & cbb.Bits) != 0)
                {
                    cb.Undo();
                    return(true);
                }
            }

            cb.Undo();
            return(false);
        }