Computer Chess Club Archives


Search

Terms

Messages

Subject: Outside passers with one and

Author: Gerd Isenberg

Date: 12:48:48 04/14/03


Hi all,

a minor pawn pattern idea, i like to share ...

With (pawn) bitboards it's pretty easy to get all passers and even to get all
outside passers. The second was new to me, and i had the idea recently (thinking
bitboards ;-), but i guess the "trick" is already common or well known.

Instead of pattern branching after a distance compare in an inner loop over
passers of one color, i use a separate bitscan and reset loop over this
dedicated set of outside passers now, eg. in pawn endings.

For outside passers one need a precalculated array of 2*64*2 bitboards.
This array is indexed by color of passed pawns we are looking for, square of
opposite king and color of side to move. It contains set bits for all squares
with distance to promotion < king distance to promote squares, considering the
tempo.

Next step may be to avoid such loops at all, to process some single properties
without further piece interactions. Most often one uses some piece-square
tables, indexed by the squares of the traversed bitboard. If only the
rank-position is significant, a simultanious (mmx) popcount of six consecutive
bytes may be interesting, where the bytewise population counts are multipied
afterwards with some weighting factors.

But the population count is most often rather small with outside passers, if
any. I guess for this purpose a bitscan-loop like is fine:

if ( bb )
{
 ...
 do something( BitScanAndReset(bb) ); while (bb); // traversing bb
}


Cheers,
Gerd




passedPawns[WHITE] = pawns[WHITE] & ~filldown(allPawns|pawnAttacks[BLACK]);
passedPawnsOutside[WHITE] = passedPawns[WHITE] &
sOutsideSquares[WHITE][bKing][color2move];

BitBoard fillDown(BitBoard b)
{
    // Uses Kogge-Stone parallel prefix algorithm
           b |= b >>  8;
           b |= b >> 16;
    return b |  b >> 32;
}


BitBoard sOutsideSquares[2][64][2];


eg.:
sOutsideSquares[WHITE][a8][WHITE] =
 o 1 1 1 1 1 1 1  // a8..h8 invalid pawn squares (8.rank) don't matter
 0 0 1 1 1 1 1 1
 0 0 0 1 1 1 1 1
 0 0 0 0 1 1 1 1
 0 0 0 0 0 1 1 1
 0 0 0 0 0 0 1 1
 0 0 0 0 0 0 1*1  // a2..h2 *considers double pawn step
 0 0 0 0 0 0 0 0  // a1..h1

sOutsideSquares[WHITE][a8][BLACK] =
 o o 1 1 1 1 1 1  // a8..h8 invalid pawn squares (8.rank) don't matter
 o o 0 1 1 1 1 1
 0 0 0 0 1 1 1 1
 0 0 0 0 0 1 1 1
 0 0 0 0 0 0 1 1
 0 0 0 0 0 0 0 1
 0 0 0 0 0 0 0*1  // a2..h2 *considers double pawn step
 0 0 0 0 0 0 0 0  // a1..h1




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.