public static UInt64 GetKnightAttacksBitboard(UInt64 knightsBitboard, UInt64 friends) { UInt64 result = 0; while (knightsBitboard > 0) { var sq = knightsBitboard.GetLeadingSquare(); knightsBitboard = knightsBitboard.Clear(sq); result |= GetKnightAttacksBitboard(sq); } return result & (~friends); }