Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitboards generate moves King, Knight

Author: Tony Werten

Date: 00:16:41 09/20/04

Go up one level in this thread


On September 20, 2004 at 03:06:54, Gerd Isenberg wrote:

>On September 20, 2004 at 02:23:59, Tony Werten wrote:
>
>>It isn't doing things parallel like the sliders with Kogge Stone, but at least
>>it doesn't use those big arrays.
>>
>>const KNIGHTC3  // all attacks of a knight on square C3
>>
>>pieces=BITBOARD[stm][KNIGHT];
>>attacks=0;
>>while (pieces)
>>{
>>   sq=bitscan_first_and_reset(pieces);
>>   File(sq)>2 ? mask=NOT_FILE_AB:mask=NOT_FILE_GH;
>>   if (sq>C3) attacks=(KNIGHTC3>>(sq-C3)) & mask;
>                                <<

correct (when A1=0 and H8=63)

>>   else attacks|=(KNIGHTC3<<(C3-sq)) & mask;
>                ??         >>

correct. I'm mixing some things here. The |= is for all knight attacks, mostly
you only want =

>>}
>>
>>For king is the same but on square B2. Since most of the time sq>C3 (or B2)
>>branch prediction should be OK.
>
>Even more for sq>=C3 (or b2).

Yeah, that might do some 0.1 % better even :)

Tony

>
>
>>
>>Tony



This page took 0.01 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.