Computer Chess Club Archives


Search

Terms

Messages

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

Author: Bas Hamstra

Date: 12:57:02 10/22/00

Go up one level in this thread


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

>Hi!
>
>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)
>
>
>// 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?
>
>Severi

I suspect it is slower overall. For the vertical part of the rookmoves, for
example, you need only 1 memory lookup with rotated BB's. The "state" of the
rank you get cheap by treating the Occupied90 BB as a character array, and
fetching the right char. Then you fetch RankMoves[State][Sq] from a table.

Of course in your case, you save a lot of big lookuptables and so cache
trashing. But I don't suspect it comes close overall.

If you don't want the big lookup tables, you probably can better try the
unrotated version where you scan for blocks with a table lookup. I and others
have had goods results with it, speedwise, and it's VERY easy.

Bas.






















This page took 0.02 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.