Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: A question about move generators for bishops and rooks

Author: Gerd Isenberg

Date: 05:48:41 04/07/04

Go up one level in this thread


On April 07, 2004 at 06:56:35, Tord Romstad wrote:

>On April 07, 2004 at 05:06:13, Gerd Isenberg wrote:
>
>>But caching/precalculation of rotated lookup that way only pays off, if you
>>really need it very, very oftern per node for a lot of squares. And most of the
>>time you really dont't need attacks from all squares...
>
>I apologize for asking a stupid newbie question (I started experimenting
>with bitboards less than a week ago):  How can you avoid computing all
>attacks from all squares when evaluating a position?


Hi Tord,

there are no stupid questions ;-)

You need only to consider those squares occupied by appropriate pieces. Pawn
attacks setwise by some shifting with masking board wraps. Sliding pieces by
bitscan and rotated lookups or setwise by Kogge Stone fill. Knights and Kings by
bitscan and lookup or setwise by some appropriate fill routine...

In crafty like rotated bitboard approaches you will find two kinds of attack
getters, one to get (rook/bishop) attacks from a square (the rotated lookups)
and another kind like getAttackedBy(int sq) to get a set of all pieces attacking
this square:

BitBoard getAttackedBy(int sq)
{
    return  ( getRookAttackesFrom(sq)  & (queens|rooks) )
          | ( getBishopAttacksFrom(sq) & (queens|rooks) )
          | ( getKnightAttacksFrom(sq) & knights )
          | ( getKingAttacksFrom(sq)   & kings )
          | ( getWPawnAttacksFrom(sq)  & blackPawns )
          | ( getBPawnAttacksFrom(sq)  & whitePawns );
}

If you need this getAttackedBy(int sq) often for a lot of squares, it may become
ineffiecient. Therefore if this is really the case it may be faster to compute
all attacks from all white/black pieces (what you have to do anyway for eval and
movegen), and to compute some taboo sets based on that piece attack sets with
simple bitwise operations...

But most often getAttackedBy(int sq) is used only for surrounding king squares
and some other critical squares e.g. to compute some SEE-values, but not for all
64 squares per se.

Depending on your program design, if you have lazy eval, legale or pseudo legal
move generation etc., you simply don't need that information at all for a lot of
(leaf)nodes.

Cheers,
Gerd

>
>Tord



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.