Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Efficient Rotated Bitboard Representations

Author: Robert Hyatt

Date: 05:06:37 10/29/98

Go up one level in this thread


On October 28, 1998 at 22:38:41, Roberto Waldteufel wrote:

>Hi all,
>
>Here is another way of mapping the diagonals for rotated bitboards, which might
>enhance the efficiency slightly for diagonal attacks. Instead of one bitboard
>for all a1-h8 oriented diagonals and one for the a8-h1 oriented diagonals, would
>it not be feasible to map the light squares twice on one bitboard and the dark
>squares twice on the other, so that on each bitboard the least significant 32
>bits hold diagonals with one orientation and the most significant 32 bits hold
>the same squares in the other orientation. Then, given an origin square, we only
>have to AND its key with a single bitboard (instead of two), and we get the
>squares in two sets of contiguous bits, one in the top 32 bits and one in the
>lower 32 bits. Using two shifts,one mov (register to register) and one OR we can
>move these bits to form one contiguous set of bits at the least significant end.
>
>For any given source square, the occupancy of squares on the diagonals through
>that square cannot affect the attacks from that square if they are on the edge
>of the board, so there can never be more than 9 squares that could affect the
>result. Thus no square's diagonal key need have more than 9 bits set, so we can
>produce an index of at most 9 bits, ie in the range 0-1023, which we can use to
>look up the attack map in a table, thus retrieving both sets of diagonal attacks
>in one go.
>
>When making/unmaking moves, it would perhaps help again. Normally when a
>square's occupancy changes it would be necessary to xor a square's bitmask with
>each of the 4 rotated bitboards, with one bit set in each of the 4 masks for
>that square. Now, however, we find that each square has two bits set in one
>diagonal bitboard and none in the other, so the masking can be done with 3
>operations instead of 4.
>
>In the evaluation function, it might also be handy to have all squares of the
>same colour in a 32-bit contiguous cluster to evaluate things like good/bad
>bishops or weak colour complexes.
>
>Any comments?
>
>Roberto


sounds doable...  only issue I see is it represents info for bishops and 1/2 of
a queen, only...  the rooks and other half of the queen moves isn't affected...



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.