Understanding magic bitboard I have read a lot of stuff about magic bitboard but some stuff is not clear. A lot of authors say to create the move masks for the piece avoiding the border positions. So, for a bishop at D3 the move mask would be this:

00000000
00000000
00000010
01000100
00101000
00000000
00101000
00000000


instead of this

00000000
00000001
00000010
01000100
00101000
00000000
00101000
01000100


They say this is good for convenience. I don't see how, but anyway, lets bear with this idea.

The problem is that, if we will avoid the border are, how will the move map for a hook at A1 be? All zeros? The hook at A1 will be like this:

10000000
10000000
10000000
10000000
10000000
10000000
10000000
11111111


but if we cannot have the numbers at the border it will be all zeros.

Is there another reason for that "avoid the border" rule? Is that OK if I forget that rule and make it to the border?
It's not about avoiding the border. It's about avoiding the last bit of the ray.

Given this:

10000000
10000000
10000000
10000000
10000000
10000000
10000000
01111111


(Note that A1 should be zero as the rook is unimportant)

You will note that along the first rank, if there is no piece on G1, then a rook can attack H1, regardless of what is on that square. This also applies along the A-file, where if there is no piece on A7, then A8 can always be attacked.

Because of this, we mask out the last bit of the ray, as we do not need to know what's at the end of the ray, producing this mask:

00000000
10000000
10000000
10000000
10000000
10000000
10000000
01111110


This produces a significant table reduction, as you need only 12 bits of occupancy to index the table, not 14.