Queem.Core.ChessBoard.PlayerBoard.GetPawnAttacks C# (CSharp) Method

GetPawnAttacks() protected method

protected GetPawnAttacks ( ) : ulong
return ulong
        protected ulong GetPawnAttacks()
        {
            if (this.position == PlayerPosition.Down)
                return this.Pawns.AnyUpAttacks();
            else
                return this.Pawns.AnyDownAttacks();
        }

Usage Example

Ejemplo n.º 1
0
        public bool IsUnderAttack(Square sq, PlayerBoard opponentBoard)
        {
            ulong occupied = 1UL << (int)sq;

            ulong pawnAttacks = opponentBoard.GetPawnAttacks();

            if ((occupied & pawnAttacks) != 0)
            {
                return(true);
            }

            ulong knights      = opponentBoard.bitboards[(int)Figure.Knight].GetInnerValue();
            ulong king         = opponentBoard.bitboards[(int)Figure.King].GetInnerValue();
            ulong otherFigures = opponentBoard.allFigures | this.allFigures;

            otherFigures &= (~occupied);

            var   knightAttackGenerator = this.attacksGenerators[(int)Figure.Knight];
            ulong occupiedKnightMoves   = knightAttackGenerator.GetAttacks(sq, otherFigures);

            if ((occupiedKnightMoves & knights) != 0)
            {
                return(true);
            }

            var   kingAttackGenerator = this.attacksGenerators[(int)Figure.King];
            ulong occupiedKingMoves   = kingAttackGenerator.GetAttacks(sq, otherFigures);

            if ((occupiedKingMoves & king) != 0)
            {
                return(true);
            }

            ulong rooksQueens   = opponentBoard.GetRooksQueens();
            ulong bishopsQueens = opponentBoard.GetBishopsQueens();

            var   rookAttackGenerator = this.attacksGenerators[(int)Figure.Rook];
            ulong occupiedRookMoves   = rookAttackGenerator.GetAttacks(sq, otherFigures);

            if ((occupiedRookMoves & rooksQueens) != 0)
            {
                return(true);
            }

            var   bishopAttackGenerator = this.attacksGenerators[(int)Figure.Bishop];
            ulong occupiedBishopMoves   = bishopAttackGenerator.GetAttacks(sq, otherFigures);

            if ((occupiedBishopMoves & bishopsQueens) != 0)
            {
                return(true);
            }

            return(false);
        }
All Usage Examples Of Queem.Core.ChessBoard.PlayerBoard::GetPawnAttacks