Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Use of square eval using Bit Boards aka Ed's Rebel Evaluation,but for bb

Author: Gerd Isenberg

Date: 09:41:39 01/08/03

Go up one level in this thread


On January 08, 2003 at 04:43:12, scott farrell wrote:

>My chompster is bit board .... bit boards rule 4ever !!!
>
>I really like Ed's code for eval/SEE, call it what you like, by calculating all
>the attack and defend squares.
>
>MSCP does this to a lesser extent.
>
>Crafty doesnt seem to do it at all. Robert, am I correct here? do you eval each
>square in a 64 byte array at all? I couldnt see it.
>
>Having used bitboards in chompster I have almost no loops anywhere in my
>program. 1 or 2 for move generation, and 1 for move ordering and 1 for searching
>each move, and only a very few in eval but all guarded by a simple bit board &
>so they dont fire too often.
>
>The only way I can think to implement the above, it to iterate over each
>attackBoard for each piece, which I have available during eval, but I dont
>really want to iterate over it, yuk ... too sssllloooowwwww.
>
>It seems to me, without bit boards, you have to iterate everything, so it seems
>no problem to be iterating over attack vectors. But for us bit-boarders it seem
>ugly (too me anyway).
>
>All I could think of was to keep each attackVector for each piece. And when
>traversing each quare on the board, do something like this:
>
>for (sq=0; sq<64;sq++){
>  if(  (mask[sq] & whiteQueenAttacks) !=0)
>    attackers++;
>  if(  (mask[sq] & blackQueenAttacks) !=0)
>    defenders++;
>  ......
>}
>if (attackers>defenders)
>    ATTACK_NOW_!!!!!
>
>atleast this method I dont have ot itereate the actuall attack vectors, and
>avoid slow msb/pop type routines.
>
>Any help / ideas appreciated.
>
>Scott

Hi Scott,

yes, Ed's control structure is really nice to have, specially if they are used
as indices of a two dimensional 256*256 table, to get a precalculated is enprise
or hanging information for pieces etc.

But with attacked bitboards it is probably smarter to use a bitboard based
approach for hanging or enprise squares or pieces, which may generated in a
loopless, unconditional way like below (on the fly, hope you get the idea).

A lot of this stuff may be done in the near future with hammers MMX- or
XMM-registers.

Regards,
Gerd

// several attack bitboards
pawnAttacks[W]       = getPawnAttacksAH(W) | getPawnAttacksHA(W);
pawnDblAttacks[W]    = getPawnAttacksAH(W) & getPawnAttacksHA(W);
knightAttacks[W]     = getKnightAttacks(W);
knightDblAttacks[W]  = getKnightDblAttacks(W);
bishopAttacks[W]     = getBishopAttacks(W);
rookAttacks[W]       = getRookAttacks(W);
rookDblAttacks[W]    = getRookDblAttacks(W);
queenAttacks[W]      = getQueenAttacks(W);
kingAttacks[W]       = getKingAttacks(W);
xRays[W]             = ....;

KnBiAttacks[W]       = knightAttacks[W]  | bishopAttacks[W];
KnBiPaAttacks[W]     = KnBiAttacks[W]    | pawnAttacks[W];
RKnBiPaAttacks[W]    = KnBiPaAttacks[W]  | rookAttacks[W];
QRKnBiPaAttacks[W]   = RKnBiPaAttacks[W] | queenAttacks[W];
allAttacks[W]        = QRKnBiPaAttacks[W]| kingAttacks[W];

// single, double and triple attacks
// (may be exceeded to quad or multiple attacks)

doubleAttacks[W]     = pawnDblAttacks[W];
singleAttacks[W]     = pawnAttacks[W];

tripleAttacks[W]     = doubleAttacks[W] & knightAttacks[W];
tripleAttacks[W]    |= singleAttacks[W] & knightDblAttacks[W];
doubleAttacks[W]    |= singleAttacks[W] & knightAttacks[W];
doubleAttacks[W]    |= knightDblAttacks[W];
singleAttacks[W]    |= knightAttacks[W];

tripleAttacks[W]    |= doubleAttacks[W] & bishopAttacks[W];
doubleAttacks[W]    |= singleAttacks[W] & bishopAttacks[W];
singleAttacks[W]    |= bishopAttacks[W];

tripleAttacks[W]    |= doubleAttacks[W] & rookAttacks[W];
tripleAttacks[W]    |= singleAttacks[W] & rookDblAttacks[W];
doubleAttacks[W]    |= singleAttacks[W] & rookAttacks[W];
doubleAttacks[W]    |= rookDblAttacks[W];
singleAttacks[W]    |= rookDblAttacks[W];

tripleAttacks[W]    |= doubleAttacks[W] & queenAttacks[W];
doubleAttacks[W]    |= singleAttacks[W] & queenAttacks[W];
singleAttacks[W]    |= queenAttacks[W];

tripleAttacks[W]    |= doubleAttacks[W] & xRays[W];
doubleAttacks[W]    |= singleAttacks[W] & xRays[W];

tripleAttacks[W]    |= doubleAttacks[W] & kingAttacks[W];
doubleAttacks[W]    |= singleAttacks[W] & kingAttacks[W];
singleAttacks[W]    |= kingAttacks[W];

singleAttacks[W]    &= ~doubleAttacks[W];
doubleAttacks[W]    &= ~tripleAttacks[W];

// dominated contols
valDom[W] = (pawnDblAttacks[W] & ~pawnDblAttacks[B])
          | (pawnAttacks[W]    & ~pawnAttacks[B])
          | (KnBiAttacks[W]    & ~KnBiPaAttacks[B])
          | (rookAttacks[W]    & ~RKnBiPaAttacks[B])
          | (queenAttacks[W]   & ~QRKnBiPaAttacks[B])
          | (kingAttacks[W]    & ~allAttacks[B]);

valDom[B] = ....

countDom[W] = (tripleAttacks[W] & ~tripleAttacks[B])
            | (doubleAttacks[W] & ~doubleAttacks[B])
            | (singleAttacks[W] & ~singleAttacks[B]);

totalDom[W] = valDom[W] | (countDom[W] & ~valDom[B]);
...

// hanging pieces (enprise)
enprise[W] = (queens[W] & RKnBiPaAttacks[B])
           | (rooks[W]  & KnBiPaAttacks[B])
           | ((knights[W]|bishops[W])& pawnAttacks[B])
           | (pieces[W] & totalDom[B]);





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.