Indeed. Much more of this kind of thing and in a real chess game I'm gonna have to face away from the board and look into a mirror in order to analyze.bob wrote:bit to square is completely irrelevant. But you want to make the LSB bit number 0, the MSB as bit 63, because that is how the BSF/BSR instructions number the bits. So long as you keep the rightmost bit as bit zero, you are set. Doesn't matter whether you map bit 0 to a1, h1, a8 or h8.Fguy64 wrote:Greetings, I was just looking into this. The standard mapping, which I have seen termed "little endian", starts with the least significant bit mapped to square a1 and the most significant bit mapped to h8. Apparently there is some sort of mathematical advantage to this mapping.
I am wondering if this so called "mathematical advantage" is just a c++ thing, which depends on the way c++ lays out it's arrays.
I have always worked with arrays or strings in java, and I know in java I have always thought of array element (0,0), or just index=0 in the case of a string, as square a8 and array element (7,7) or index=63 as square h1. Which is the same general layout as a fen string.
So the question is whether or not so called optimal bit/square mappings are language dependant.
Thanks.
In Crafty, when I renumbered things, I went thru a bit of an interesting mapping, as for me, bit 0 is a1, bit 7 is h1, ... bit 56 is a8, bit 63 is h8. If you look at a bitboard and want to visualize it, you have to mentally look at it through a mirror. I don't find this hard at all, although at first it took some concentration.
Anyways, thanks, your answer intuitively makes sense. At first I was thinking about the mapping between bit positions and the indexes of an expanded position string, but that is irrelevant for the way things are actually coded.
And here's a thought.. I suppose the most visually intuitive might be to map MSB to a8 and LSB to h1, and if it really doesn't matter from a coding perspective, to my that seems to eliminate the aforementioned mirror effect, I just have to wipe the concept of fen String from my mind.