Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: quick bitboard question

Author: Dan Honeycutt

Date: 14:30:55 08/26/05

Go up one level in this thread


On August 26, 2005 at 17:01:16, Robert Hyatt wrote:

>On August 26, 2005 at 16:55:28, Dan Honeycutt wrote:
>
>>On August 26, 2005 at 16:36:47, Dan Honeycutt wrote:
>>
>>>On August 26, 2005 at 16:15:47, Robert Hyatt wrote:
>>>
>>>>On August 26, 2005 at 16:11:53, Dan Honeycutt wrote:
>>>>
>>>>>Run the lowest bits down the a or h file and you can do pawn captures without
>>>>>having to mask those files.
>>>>>
>>>>>Best
>>>>>Dan H.
>>>>
>>>>
>>>>How would you avoid masking?  Otherwise the pawn at h2 would still wrap to a3 on
>>>>a shift...
>>>
>>>h8 = bit 0
>>>h7 = bit 1
>>>:
>>>a1 = bit 63
>>>
>>>If I ran that the right way, the out of bounds bits are lost and 0's are shifted
>>>in on the other side.
>>>
>>>Best
>>>Dan H.
>>
>>Looking at it, I think that's right.  Take white pawns on g4 and h4 with
>>captures to the right.  g4 is bit 12 and h4 is bit 4.  My shift is 9 left, so g4
>>lands on h5 (bit 3) and h4 is discarded.
>>
>>Best
>>Dan H.
>
>
>The problem is that all 64 squares are represented by one bit.  So no matter
>what you do, a pawn on the edge is going to wrap around to the other side of the
>board...  Because all 64 bits are shifted at once...
>
>Are we talking about the same thing here???

Before      After (shifting all 64 bits 9 left)
sq  bit     sq  bit
h8  0       gone
h7  1       gone
h6  2       gone
h5  3       gone
h4  4       gone
h3  5       gone
:
g4  12      h5  3
:
a1  63      b2  54
           (bits 55 to 63 - squares b1 and the a file - are all 0)

So my white pawn on g4 who I want to capture on a5 is in the correct bit 3.  My
white pawn on h4 (who I do not want to capture on a5 or any other square) has
been shifted out.  I take the After bitmap, "and" it with the black pieces and
I've got my pawn captures (half of them) with no need to mask the h file.

Best
Dan H.





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.