Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Traversing bitboards in a symmetrical way

Author: Zach Wegner

Date: 03:26:08 08/04/03

Go up one level in this thread


On August 04, 2003 at 06:11:20, Gerd Isenberg wrote:

>Hi all,
>
>One common search/evaluation test is to compare the search of a position with
>it's mirrored position.
>
>There is one principle problem related to bitboard traversal in move-generation.
>
>Black pieces and targets are traversed in an other order than the "mirrored"
>pieces and targets, regardless if one uses bsf or bsr and the square-bitindex
>mapping.
>
>Lets take some white pawns with following bit indicies: b2(9),d2(11) and c3(18).
>With bsf you'll find them in ascending order: b2,d2,c3. Now with "mirrored"
>black pawns on b7(49),d7(51),c6(42) we will foreward scan the ascending c6,b7,d7
>squares.
>
>Even if there is further move sorting, the different initial order of generated
>moves in mirrored positions implies different search trees - and therefore
>slightly different search results.
>
>How do you deal with this behaviour in your bitboard based program?
>I ignore it so far.
>
>One possible solution with x86-64 is to use the fast "bswap reg64" instruction
>(direct path,1 cycle) before scanning black pieces or targets for movegen.
>"bswap" mirrors the bits rankwise (8 becomes 1, 7 become 2...) and a remirror of
>the scanned bit index is a simple xor with 0x38.
>
>According to the sample above we mirror the black b7,d7,c6 pawns to b2',d2',c3'
>and we get the same order as with original white pawns: b7,d7,c6.
>
>One drawback is of course the need of a color2move paramter for bitScan - or
>separate black/white traversal.
>
>Any remarks or implementaion hints?
>
>Regards,
>Gerd

What I have always done, which avoids this problem, is to use either MSB or LSB
for removing a piece depending on which side of the board it is most likely to
be on. e.g. for white pawns, use LSB; for black pawns, use MSB. I dont know if
this helps, but it couldn't hurt.



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