Computer Chess Club Archives


Search

Terms

Messages

Subject: Efficient Rotated Bitboard Representations

Author: Roberto Waldteufel

Date: 19:38:41 10/28/98


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



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.