Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: quick bitboard question

Author: Tony Werten

Date: 22:00:08 08/26/05

Go up one level in this thread


On August 26, 2005 at 15:04:55, Robert Hyatt wrote:

>I'm fixing to change the way I number bits to make bit 0 the LSB (as the BSF/BSR
>instructions count on the X86) rather than the MSB as the leading zero
>instruction counts on the Cray-1 architecture.
>
>I have four choices for which square bit 0 represents (four logical choices,
>anyway, I guess one could number bits randomly should they choose).
>
>A1 = 0
>H1 = 0
>A8 = 0
>H8 = 0
>
>For those of you using bitboards, which did you use?  Since it doesn't matter to
>me at all, since I am having to rewrite a bunch of stuff to make this work, I
>thought I would try to match the most common layout which will make the programs
>more compatible if we share any ideas.
>
>I am leaning toward H1 = 0, H2 = 8, ..., H8 = 56 and A8 = 63, but I've not made
>any decision yet...  The reason for this is that it is easier to visualize if
>you think of the chess board as being composed of the 1 rank and the rightmost 8
>bits of the bitboard, the 2nd rank is the next 8 bits, etc.
>
>The alternative is H8=0, etc, so that the last rank is the rightmost bits, the
>seventh rank is the next 8 bits, etc.  Anything else requires "mentally
>mirroring" so that if A1 or A8 is bit zero, the bits are backward, since A8 is
>the left end of a rank, and bit 0 is the right end of a set of 8 bits...

I use A1=0,H1=7,H8=63.

Same for pawnbytes. A pawn on the A file will the 0 bit set. It seemed logical
from programming point of view. You just have to get used to it.

I did however make a function ShowBB() wich shows the bitboard in a chessboard
view, for checking bitboard patterns.

BTW since you start changing anyway, you might want to reconsider your
diagonally rotated bitboards. Making them 8 times 8 bits each by lining up
A1-H8,A2-G8+H1,A3-F8+G1-H2  etc makes them a lot easier to visualize.

In addition it gives the possibility to get "ranks" by charptr[rank] rather than
a shift. Well, at least that's nice for my program, I swap a lot between bb and
0x88

Tony






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.