Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: quick bitboard question

Author: Alessandro Damiani

Date: 16:29:55 08/27/05

Go up one level in this thread


On August 27, 2005 at 13:38:12, Gerd Isenberg wrote:

>On August 27, 2005 at 06:44:14, Alessandro Damiani wrote:
>
>>On August 27, 2005 at 06:40:43, Alessandro Damiani wrote:
>>
>>>On August 27, 2005 at 05:54:16, Gerd Isenberg wrote:
>>>
>>>>On August 27, 2005 at 05:33:17, Alessandro Damiani wrote:
>>>>
>>>>>On August 27, 2005 at 03:12:23, Gerd Isenberg 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.
>>>>>>
>>>>>>Hi Dan,
>>>>>>
>>>>>>a very nice idea! Keeping the a-file in least significant byte and the h-file in
>>>>>>the most significant byte (or vice versa) to avoid a-h-wraps for pawn attacks
>>>>>>and further ands.
>>>>>>
>>>>>>eg. with a1 == 0:
>>>>>>
>>>>>>a1 a2 a3 a4 a5 a6 a7 a8
>>>>>>b1 b2 b3 b4 b5 b6 b7 b8
>>>>>>c1 c2 c3 c4 c5 c6 c7 c8
>>>>>>d1 d2 d3 d4 d5 d6 d7 d8
>>>>>>e1 e2 e3 e4 e5 e6 e7 e8
>>>>>>f1 f2 f3 f4 f5 f6 f7 f8
>>>>>>g1 g2 g3 g4 g5 g6 g7 g8
>>>>>>h1 h2 h3 h4 h5 h6 h7 h8
>>>>>>
>>>>>>"left" attacks of white pawns  ::= white pawns >> 7 ; eg. e4:d5
>>>>>>"right" attacks of white pawns ::= white pawns << 9 ; eg. e4:f5
>>>>>>"left" attacks of black pawns  ::= black pawns >> 9 ; eg. e4:d3
>>>>>>"right" attacks of black pawns ::= black pawns << 7 ; eg. e4:f3
>>>>>>
>>>>>>Gerd
>>>>>
>>>>>A nice idea indeed, but then vertical shifting needs masking, e.g. shiftUp(e8) =
>>>>>f1. So, no real gain in the end, I guess.
>>>>>
>>>>>Or do I miss something?
>>>>>
>>>>>Alessandro
>>>>
>>>>Since pawns usually don't stay on back ranks, there is no need to worry about
>>>>rank1/8 pawn push wraps. So for pawns there is a small gain for their attacks.
>>>>For x86-32 it might be negligible since the double register shifts are much more
>>>>expensive than two "ands" with immediate operands.
>>>>
>>>>For x86-64 there is only one reg64 shift. The "and reg64, mem64" reads the mask
>>>>from memory - so the relative gain might be more significant here.
>>>>
>>>>Gerd
>>>
>>>Sorry, I mistakenly thought to apply this method to all piece bitboards. But,
>>>right, if only applied to pawns then there is no drawback.
>>>
>>>Alessandro
>>
>>To determine the squares in front of the pawns we still need to mask. Something
>>used in eval.
>>
>>Alessandro
>
>Alessandro,
>i fail to see why it is necessary to mask for pawn pushs:
>
>a1 a2 a3 a4 a5 a6 a7 a8
>b1 b2 b3 b4 b5 b6 b7 b8
>c1 c2 c3 c4 c5 c6 c7 c8
>d1 d2 d3 d4 d5 d6 d7 d8
>e1 e2 e3 e4 e5 e6 e7 e8
>f1 f2 f3 f4 f5 f6 f7 f8
>g1 g2 g3 g4 g5 g6 g7 g8
>h1 h2 h3 h4 h5 h6 h7 h8
>
>let say white pawns on a7,b7, black pawns on g2,h2
>
>a1 a2 a3 a4 a5 a6 wp a8
>b1 b2 b3 b4 b5 b6 wp b8
>c1 c2 c3 c4 c5 c6 c7 c8
>d1 d2 d3 d4 d5 d6 d7 d8
>e1 e2 e3 e4 e5 e6 e7 e8
>f1 f2 f3 f4 f5 f6 f7 f8
>g1 bp g3 g4 g5 g6 g7 g8
>h1 bp h3 h4 h5 h6 h7 h8
>
>square shift left one (bit shift right) for white pawn pushes,
>square shift right (bit shift left) one for black pawn pushes,
>to get the promote targets.
>
>a1 a2 a3 a4 a5 a6 wp->>
>b1 b2 b3 b4 b5 b6 wp->>
>c1 c2 c3 c4 c5 c6 c7 c8
>d1 d2 d3 d4 d5 d6 d7 d8
>e1 e2 e3 e4 e5 e6 e7 e8
>f1 f2 f3 f4 f5 f6 f7 f8
><<-bp g3 g4 g5 g6 g7 g8
><<-bp h3 h4 h5 h6 h7 h8
>
>so result is
>whitePawnPromotePushes{a8,b8}
>blackPawnPromotePushes{g1,h1}
>
>Since i like to combine all bitboards with the same mapping, i would use this
>"vertical" mapping for all other pieces as well. Fill stuff works as well as
>rotated of course (except that the none rotated maps consequtive squares on a
>file rather than on a rank). While rooks left/right kogge stone need no
>wrap-ands, but therefor up/down. Diagonal attacks needs wrap-ands anyway.
>
>Or did i miss something?
>
>Gerd

Sorry Gerd! Now I know I didn't sleep enough.

Das nächste Mal antworte ich so um 1 Uhr 30 in der Nacht, wie jetzt gerade, da
bin ich offenbar hellwach. ;-)

Alessandro

P.S. Earth is a bitboard.



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.