Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Reverse Bitboards - correction

Author: Gerd Isenberg

Date: 03:02:02 01/15/03

Go up one level in this thread


<snip>
>>The final xor resets the remaining rook bits, but sets all occupied bits that
>>became previously reset by the second subtraction.

Wrong!

>>
>>For single attackers the trick also works in other positive (or reversed
>>negative) directions with some additional ray masks and 64-bit arithmetic.
>
>Thanks for that excellent explanation.

Thanks for the compliment ;-)
Trying to explain something improves my own understanding.

- - X - - - - -
- R - - R - - -
- - - - - - - -
- X - R - - X -
- - - - - - - -
- R X - R - X -
- - - - - - - -
R - - - - - - -

BitBoards: - is zero for better reading. All operations byte- or rankwise.
0 1 2 3 4 5 6 7

   Occupied         Rooks       Occupied-Rooks  Occupied-2Rooks...^Occupied
- - 1 - - - - -|- - - - - - - -|- - 1 - - - - -|- - 1 - - - - -|- - - - - - - -
- 1 - - 1 - - -|- 1 - - 1 - - -|- - - - - - - -|- 1 1 1 - 1 1 1|- - 1 1 1 1 1 1
- - - - - - - -|- - - - - - - -|- - - - - - - -|- - - - - - - -|- - - - - - - -
- 1 - 1 - - 1 -|- - - 1 - - - -|- 1 - - - - 1 -|- 1 - 1 1 1 - -|- - - - 1 1 1 -
- - - - - - - -|- - - - - - - -|- - - - - - - -|- - - - - - - -|- - - - - - - -
- 1 1 - 1 - 1 -|- 1 - - 1 - - -|- - 1 - - - 1 -|- 1 - - 1 1 - -|- - 1 - - 1 1 -
- - - - - - - -|- - - - - - - -|- - - - - - - -|- - - - - - - -|- - - - - - - -
1 - - - - - - -|1 - - - - - - -|- - - - - - - -|1 1 1 1 1 1 1 1|- 1 1 1 1 1 1 1
       x               1              x-1             x-2           x^(x-2)

The first subtraction "resets" the rook bits.

The second subtraction toggles the bits from the rook bit positions in MSB
direction (right board direction) until the first occupied is toggled and
becomes zero.

The final xor resets the remaining Occupied bits, except the ones previously
reset by the second subtraction.

Gerd






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.