Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Rotated bitboards

Author: Peter Fendrich

Date: 02:19:35 04/23/98

Go up one level in this thread


On April 22, 1998 at 23:52:53, Robert Hyatt wrote:

>On April 22, 1998 at 17:09:02, Bruce Moreland wrote:
>
>>
>>On April 22, 1998 at 16:57:00, Peter Fendrich wrote:
>>
>>>There seems to be different definitions of what rotated bitboards really
>>>are. I'm talking about rotating the diagonals.
>>>
>>>What should be called rotated?
>>>
>>>1) Rotate the board 45 degrees. Now we have 15 diagonals on 15 bytes.
>>>   This would be truly rotating in my defintion. Not so good however,
>>>   because we cant't use the 64 length bitboard to store it in.
>
>scratch this.  bitboards are, by definition, 64 bits.  So any mapping
>that leads to more than 64 bits is useless...

I did! But this is what true roating should result in, or maybe this is
another language misunderstanding...

>
>>>
>>>2) Map the squares so that adjecent squares on the same diagonal
>>>   recides on the same byte.
>>>   This isn't really rotating, shouldn't it be called something else?
>>>   Mapping?
>
>
>
>forget "bytes".  that's not necessary.

Right! In this sense I mean just 8 bits. I use the byte-analogy to get a
clear picture in my mind of how the bits are really structured on the
board. Extremely important during debugging if you don't want your brain
to melt down...
I like to view the board as 8x8 even when it's roatated.

>The trick is that squares on the
>same diagonal have to be mapped to adjacent bits in a word, nothing more
>or less.  There are several such "mapping" approaches.  I turn the board
>up on a corner (like a1) so that a1 is the first bit, a2/b1 are the next
>two bits, a3/b2/c1 are the next three, etc.  To extract a diagonal, you
>need to know how far to shift the rotated bitmap to the right, and then
>which mask to extract the diagonal bits... or, do as I do and don't do
>the mask at all, just take 8 bits and use that (even though some diags
>are shorter, you can initialize tables so that the extra bits are
>effectively
>ignored...
Yes, but I use masking when initializing attack boards for bishops.

Looking at this I can't see any real differences between different
mapping approaches as long as the squares on the same diagonal are
adjacent.
One has to handle the whole 64-bit word, one has to extract the bits by
shifting.
I first tried something like:
union aBitBoard {
 __int64 all;
 long   half[2];
 char   row[8];
}
I then mapped the *white* diagonals to half[1] and the *black* diagonals
to half[0] and hoped to be able to use the faster long instead of the
int64 (I had a P90). In the code I couldn't find any way to do this,
because of the necessary selection of which half to use which stole
CPU...

So, it still comes down to what is best suited in your own mind to
understand what's your doing...

>
>>>
>>>   I do this by packing the rotated bitboard. Start with a1 which is the
>>>   only square in the first diagonal. Put it togeteher with the nearest
>>>   diagonal with 7 squares, that is a7-g1. Next byte will be a2-b1
>>>   concatenated with a6-f1. And so on. When looking at the square a2 one
>>>   have to first mask away a6-f1.
>>>   This works fine for me.
>>>
>
>
>nothing wrong with that at all...
>
>>>3) Are there other ways of rotating the diagonals?
>>
>>The "wind from the west" board would be as follows:  Bit 0 is h1, bit
>>1-2 is g1..h2, bit 3-5 is f1..h3, bit 6-9 is e1..h4, etc.
>>
>>You don't have to treat the thing as an array of bytes, if you want to
>>get e1..h4 you can just AND the thing with 0x00000000000003C0.
>>
>>This fits in 64 bits and covers all the squares.
>>
>>This is Bob stuff.
>>
>>bruce



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.