Author: Gerd Isenberg
Date: 10:06:30 09/14/02
Go up one level in this thread
On September 14, 2002 at 12:41:02, Alessandro Damiani wrote:
>On September 14, 2002 at 07:27:17, Steffan Westcott wrote:
>
>>On September 14, 2002 at 04:33:40, Sune Fischer wrote:
>>
>>>On September 14, 2002 at 04:10:46, Sune Fischer wrote:
>>>
>>>>I just thought of another application on the passed pawns.
>>>>This way one doesn't need a 8x64 byte table or calls to firstone().
>>>>I can't say if it's faster than the lookup though, I'll probably
>>>>use it anyway.
>>>>
>>>>//===================================================================
>>>>// find the passed and semi-passed pawns:
>>>>
>>>>BITBOARD WhitePassedPawns(BITBOARD w_pawns,BITBOARD b_pawns) {
>>>> BITBOARD passed=0,tempA,tempB;
>>>> int i=0;
>>>>
>>>> tempA=(w_pawns<<8)&~b_pawns;
>>>> while (tempA) {
>>>> tempB=tempA&rank8;
>>>> i+=8;
>>>> if (tempB) // a pawn has reached the 8th rank
>>>> passed|=tempB>>i; // shift it back to where it originally came from
>>>> tempA=(tempA<<8)&~b_pawns;
>>>> }
>>>> return passed;
>>>>}
>>>
>>>Actually this may be faster, on 64 bit chips anyway:
>>>
>>> while (tempA) {
>>> passed|=(tempA&rank8)>>(i+=8);
>>> tempA=(tempA<<8)&~b_pawns;
>>> }
>>
>>
>>Sune,
>>
>>Somewhat simpler and faster still (!) is this approach :
>>
>>
>>---- CUT HERE ----
>>
>>BitBoard FillDown(BitBoard b)
>>{
>> // Uses Kogge-Stone parallel prefix algorithm
>> b |= b >> 8;
>> b |= b >> 16;
>> return b |= b >> 32;
>>}
>>
>>
>>BitBoard WhiteSemiPassedPawns(BitBoard w_pawns, BitBoard b_pawns)
>>{
>> return w_pawns & ~FillDown(b_pawns);
>>}
>>
>>
>>BitBoard WhitePassedPawns(BitBoard w_pawns, BitBoard b_pawns)
>>{
>> return w_pawns & ~FillDown( b_pawns
>> | ShiftDownLeft (b_pawns)
>> | ShiftDownRight(b_pawns));
>>}
>
>I like your approach very much. Until now I used table lookup to determine the
>flooded squares for each file (as a function of the bit pattern of each file).
>
>There is just a small improvement to your method "WhitePassedPawns()": factor
>out the "shift down" to avoid shifting down twice.
>
>BitBoard WhitePassedPawns(BitBoard w_pawns, BitBoard b_pawns)
>{
> return w_pawns & ~FillDown( b_pawns
> | ShiftDown( ShiftLeft (b_pawns)
> | ShiftRight(b_pawns));
>}
>
>Alessandro
Hi Alessandro,
Are you sure that your's is faster, Steffan has only two shift instructions, you
three?
Gerd
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.