Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Truly stupid bitboard question -- why rotate them?

Author: James Robertson

Date: 22:20:36 03/22/99

Go up one level in this thread


On March 22, 1999 at 21:38:52, KarinsDad wrote:

>On March 22, 1999 at 20:44:59, Greg Lazarou wrote:
>
>>Do you really rotate them, or do you maintain the board in straight, 45 degree
>>(diagonals), 90 degree and 135 degree angles throughout?
>>
>>Greg
>

I use a large number of bitboards; 1 for black, 1 for white, 1 for both, 3
rotations, and 1 for each piece type (white pawn, black rook, etc.), plus
rooksQueens and bishopsQueens for each color. This makes a grand total of 22
bitboards (if I added correctly). When I make a move, I usually only have to
update 5 or 6, and this is very fast.

My boards are "pre-rotated" when the board is set up, so I never have to rotate
anything in the search. If I want to update a rotated board, I just xor it with
a rotated mask.

James

>I maintain the board in each orientation for each side and for an xor of the two
>sides and copy the boards into a position's child position, and then make the
>modification in each orientation for each move (which for me is currently 12
>ANDs and 8 ORs, one OR for moving side, one AND for moving side, one AND for
>side attacked, and one OR and one AND for xor board for each of the 4
>orientations, but I will check someday to see if it is faster to just handle the
>white and black bitboards and then just xor them into a third bitboard as
>needed).
>
>Since this requires 138 bytes (3 boards * 2 orientations * 8 bytes per board + 3
>boards * 2 orientations * 15 bytes per board for diagonals), this scheme is a
>memory hog and wastes 7 bytes of data per board for the diagonals. I'm sure
>someone has come up with a fast way to rotate them, but I haven't had time to
>research it.
>
>I also use my bitboards to determine piece attacks, square control, king safety,
>open ranks, files, and diagonals (although I do not use the open diagonal info
>yet) etc. (in addition to generating moves as per James' message).
>
>KarinsDad
>
>>
>>On March 22, 1999 at 18:29:07, James Robertson wrote:
>>
>>>On March 22, 1999 at 17:06:44, Dann Corbit wrote:
>>>
>>>>I understand that you can represent a chess board as a rotated bit sets.  But my
>>>>significantly stupid question is "Why rotate them -- what is the advantage?"
>>>
>>>To generate moves, you extract 8 adjacent bits from your 64-bit bitboard. This
>>>works great for rank moves since they are already perfectly lined up. But if you
>>>want to get file moves, you can't extract every 8th bit, and diagonal moves are
>>>even worse. If you rotate the bitboard, you can extract file and diagonal moves.
>>>
>>>James



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.