Computer Chess Club Archives


Search

Terms

Messages

Subject: Bitboards generate moves King, Knight

Author: Tony Werten

Date: 23:23:59 09/19/04


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;
   else attacks|=(KNIGHTC3<<(C3-sq)) & mask;
}

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

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.