Beispiel #1
0
        public static ulong PseudomoveBitboard(int piece, int[] board)
        {
            PieceType pt = Util.GetPieceType(piece);

            switch (pt)
            {
            case PieceType.Pawn:
                return(PawnMoveGenerator.PseudomoveBitboard(piece, board));

            case PieceType.Night:
                return(KnightMoveGenerator.PseudomoveBitboard(piece));

            case PieceType.Bishop:
                return(BishopMoveGenerator.PseudomoveBitboard(piece));

            case PieceType.Rook:
                return(RookMoveGenerator.PseudomoveBitboard(piece));

            case PieceType.Queen:
                return(QueenMoveGenerator.PseudomoveBitboard(piece));

            case PieceType.King:
                return(KingMoveGenerator.PseudomoveBitboard(piece));

            default:
                break;
            }

            return(0);
        }
Beispiel #2
0
        //generate bitboard of moves
        public static ulong PseudomoveBitboard(int piece, int[] board)
        {
            bool  isWhite   = Util.IsWhite(piece);
            int   position  = Util.GetPieceOffset(piece);
            int   positionX = Util.GetXForPosition(position);
            int   positionY = Util.GetYForPosition(position);
            ulong result    = 0;
            ulong one       = 1;

            if (isWhite)
            {
                if (positionY < 6)
                {
                    if (board[position + 8] == 0)
                    {
                        result |= (one << (position + 8));
                    }

                    //captures
                    if (positionX > 0)
                    {
                        result |= (one << (position + 7));
                    }

                    if (positionX < 7)
                    {
                        result |= (one << (position + 9));
                    }
                    //initial double move
                    if (positionY == 1)
                    {
                        result |= (one << (position + (2 * 8)));
                    }
                }
                else if (positionY == 6)
                {
                    //pawn promotion
                    result |= QueenMoveGenerator.PseudomoveBitboard((PieceTypeFENMap.PieceValue('Q') + position + 8));

                    if (positionX > 0)
                    {
                        result |= QueenMoveGenerator.PseudomoveBitboard((PieceTypeFENMap.PieceValue('Q') + position + 7));
                    }

                    if (positionX < 7)
                    {
                        result |= QueenMoveGenerator.PseudomoveBitboard((PieceTypeFENMap.PieceValue('Q') + position + 9));
                    }
                }
            }
            else
            {
                if (positionY > 1)
                {
                    if (board[position - 8] == 0)
                    {
                        result |= (one << (position - 8));
                    }

                    //captures
                    if (positionX < 7)
                    {
                        result |= (one << (position - 7));
                    }

                    if (positionX > 0)
                    {
                        result |= (one << (position - 9));
                    }

                    //initial double move
                    if (positionY == 6)
                    {
                        result |= (one << (position - (2 * 8)));
                    }
                }
                else if (positionY == 1)
                {
                    //pawn promotion
                    result |= QueenMoveGenerator.PseudomoveBitboard((PieceTypeFENMap.PieceValue('q') + position - 8));

                    if (positionX < 7)
                    {
                        result |= QueenMoveGenerator.PseudomoveBitboard((PieceTypeFENMap.PieceValue('q') + position - 7));
                    }

                    if (positionX > 0)
                    {
                        result |= QueenMoveGenerator.PseudomoveBitboard((PieceTypeFENMap.PieceValue('q') + position - 9));
                    }
                }
            }

            return(result);
        }