Computer Chess Club Archives




Subject: Re: An idea to generate rook moves without rotated BBs

Author: Robert Hyatt

Date: 20:14:16 10/22/00

Go up one level in this thread

On October 22, 2000 at 11:26:58, Severi Salminen wrote:

>I have started again from scratch to program a chess engine, now with C. I came
>to this solution to generate rook moves without rotated bitboards:
>I wont show you everything :) but here is some code from my mov_gen routine. E
>holds all the pieces on board, j is the position of our Rook (0=H1 and 63=A8). F
>is an empty bitboard and D holds the horizontal squares which we can move to
>(calculated before this)

Keeping my comment simple, it is _easy_ to write a move generator with a
loop (you have an 8-square loop at the top of the code below).  Rotated
bitmaps have _no_ loops of any kind to produce a bitmap with all the
squares a rook attacks, both ranks and files.

>// Aligning the file info to right corner of bitboard and clearing all other
>// bits:
>        E=(E>>(j&7))&0x0101010101010101;
>        for(k=0, F=0;k<8;k++)
>  	{
>	   F|=E;
>	   E>>=7;
>	}
>	F&=0xff;
>//After the loop F holds the file info and we can fetch the squares from
>//a pre-compiled table and OR them with the horizontal destination squares
>	D|=FileMoves[j>>3][F]<<(j&7);
>What I'd like to know if anyone has tried to compare this method with rotated
>bitboards and I'd like to know if this is a lot slower (or faster;). I _must_ do
>this loop (which can be optimized a little...) for every rook but I don't have
>to update rotated bitboards at all after I make moves. Maybe the net speed is
>quite equal and depends on move ordering and so on...Opinions?

That is harder to evaluate.  On a 64 bit machine, updating 3 64 bit words
(the rotated bitmaps) is not expensive.  On a 32 bit machine, it is more
expensive.  But it feeds the superscalar pipes quite well with no branches to
scruff up the works.

Whether your code is faster or slower depends on lots of hardware issues.
Best bet is to bench it on the cpu you want to run on.


This page took 0.01 seconds to execute

Last modified: Thu, 07 Jul 11 08:48:38 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.