Scrambling squares for magic bitboard?

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Scrambling squares for magic bitboard?

Post by Evert »

That's pretty much what magic multiplication is intended to do though: scatter the relevant occupancy bits to the upper N bits, so these N bits can be used to index a table of possible moves for the given occupancy. I don't think pre-scrambling the board will do anything.

What might be interesting to try is to bswap() the board for squares on the lower half and bswap() the resulting move set. This reduces the required size of the table (you only need 32 squares) and gets rid of the difficult square a1. Might not be worth it with two conditional bswaps though...
User avatar
hgm
Posts: 28475
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Scrambling squares for magic bitboard?

Post by hgm »

The advantage of scrambling the squares is that you can move all the occupancy bits relevant for the most difficult squares (the Rook corners, so the edge bits) to the LSB side. This gives them more room to interact with each other through multiplications, and thus allow for a sub-minimal magic.