I understand the fundamental goal, which is to take a sparsely-populated 64-bit number and, though multiplication by a magic factor, "compress it" so that it can be used as an index lookup to a precomputed array. In other words, if only a few bits of a 64-bit number are turned on, it should be possible to represent it using something less than 2^64.
Am I correct that magic bitboards really don't work unless the bits are "in a line"? i.e., they work for sliding piece attacks, but would not if you had a few squares in a bitboard lit but they were are scattered all over the board?
For example, let's say I want to add a penalty/bonus to a score based on the position of knights on the board (center = bonus, rim = penalty, etc.) One way would be to have a bonus_array[square_num], then take the bitboard that represents a side's knights, bit scan forward through it, and lookup each square in bonus_array[], etc.
I'm wondering if there is an alternative way of pre-generating all the possible positions, then taking the knight bitboard, applying magic, and looking it up in the array, etc.
This isn't practical for all theoretical cases, as it is possible there could be 10 knights on one side. Just considering 64 C 9 is already 110 billion+ combinations. However, the vast, vast majority of the time, there will be 0 - 2 knights. That's 64 C 2 + 64 C 1 + 64 C 0 = 3906 + 64 + 1 = 3970 (don't trust my math, though

Of course, those 3970 combinations will be spread all over the 64-bit space. So is it possible to magic-fy them down a reasonable number to lookup in an array?
The same thing could be done for the King's position, since there's only one, though I'm not sure if bitmap + magic, then array lookup is faster than one bitscan, then array lookup.