# Computer Chess Club Archives

## Messages

### Subject: Re: Natural move generation with bitboards (was Re:significant math)

Author: Alessandro Damiani

Date: 12:23:55 11/21/02

Go up one level in this thread

```On November 21, 2002 at 06:47:24, Steffan Westcott wrote:

>On November 21, 2002 at 05:55:59, Alessandro Damiani wrote:
>
>>And for sliding pieces? The distance between the from- and the to-square is not
>>fixed. In the worst case, for each to-square there are 7 from-squares for one
>>direction. Do you keep one bitboard for each distance in one direction, ordered
>>from 1 to 7? Just my first thought.
>
>No, just one bitboard is used to store all possible destination squares for,
>say, upward rook moves. Look for my example routines FillUpOccluded(),
>FillRightOccluded(), etc in the CCC archives (when they get updated, eventually
>:-< ) for a suggestion on how to calculate this type of bitboard quickly.
>

I already understood the concept with "one bitboard for each direction". Let's
take a look at the example position I gave in a previous post (here again):

[D]4r1k1/2q2pp1/p1p4p/Pp1b4/1P6/2N1PN2/4QPPP/3R2K1 w - - 0 1

The bitboard for *all bishops right-down* is:

::::::::
::::::::
::::::::
::::::::
::::#:::
:::::#::
::::::::
::::::::

As you said, each time a move is searched, its to-square is removed from the
bitboard. We look at the bitboard above as a generic state in the generation
process (part of the invariant). By knowing the direction "right-down" we start
at the left-up most bit set to 1, right? Do you keep an additional invariant
related to the from-square? Or do I like the from-square far too much?? *g*

I wrote my own method for attack detection two years ago. It is not Rotated
Bitboards. I call it Rotated Indices. Bob Hyatt reported that my method is a
little bit faster than his on 32bit machines, while on 64bit it is not clear.
The chess-specific improvements I added later were not used in the tests. My

So, for the time being I don't need a new attack detection. I may change to your
flooded bitboards when they are faster than mine on a 64bit monster. ;)

But I already flooded all the weak pawns and squares. hehe Thanks!

Alessandro

```