Hi

I’m new to chess programming. I am struggling with some aspects of magic bitboards despite researching them and am hoping someone can give some quick answers.

I know the process:

OccupancyBB=AllpiecesBB & RookMaskBB[sq]

OccupancyBB*magic no[sq] >> 64 – bits = index

So does a square only ever 1 magic number associated with it? Does the magic number have to be different for every square? How do you know if it’s magic i.e. suitable?

What is bits – is it the number of squares, the Rook in this example, can potentially attack from square it is located at minus edge squares? Do you have to account for every permutation of this for each square or is one bitboard mask enough?

The OccupancyBB is an unsigned 64 bit and multiplying by magic increases its size. What is the shift to the right trying to achieve? A basic analogy would be helpful.

Can someone explain in a plain english what the formula does and idea behind it? From my basic knowledge of hash tables the aim seems to be to generate a unique index to relate to this input algorithm. Also I’ve read you have to account for RookMasks (or BishopMasks) permutations on each square and put it through this algorithm?

Thanks

Daz