Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Rotated Bitboards

Author: Bo Persson

Date: 13:44:30 05/11/99

Go up one level in this thread


On May 11, 1999 at 02:53:26, KarinsDad wrote:

[snip]

>Similar to how you do it, rotated bitboards keep track of what the normal
>bitboards keep track of, but in a 45 or 135 degree direction. At the moment, my
>code has 16 bytes to represent each rotated direction (although this can be done
>in 8 bytes, I will explain shortly). There are 15 45 degree diagonals and 15 135
>diagonals on a chess board. So, my 16 byte structure has an extra unused byte.
>Secondly, for the 45 degree diagonal (a1, a2-b1, a3-c1, etc.), there are 2 bytes
>that have no meaning, a1 and h8 (the next diagonal square for them in both
>directions is off of the board). The same applies to the 135 degree diagonals,
>however, the unused bytes are h1 and a8. So, in reality, I am using 13 bytes out
>of my 16 byte structure.
>

It's interesting to see that you too are using boards rotated 45 and 135
degrees! Crafty's diagonal bitboards are actually rotated +/- 45 degrees. It
took me a very long time to realize why my code differed from Crafty.  :-)

[snip]

>The only difference is the indexing into the array (which for me is row + column
>+ 1, row for 45 diagonals; row + column + 1, column for 135 diagonals; column,
>row for horizontal; row, column for vertical).

I don't compute an index for the diagonals, but instead use table lookups to
transform the index:

const SQUARE   Rotate45[SQUARES] =
      {a1,b2,c3,d4,e5,f6,g7,h8,
       a2,b3,c4,d5,e6,f7,g8,h1,
       a3,b4,c5,d6,e7,f8,g1,h2,
       a4,b5,c6,d7,e8,f1,g2,h3,
       a5,b6,c7,d8,e1,f2,g3,h4,
       a6,b7,c8,d1,e2,f3,g4,h5,
       a7,b8,c1,d2,e3,f4,g5,h6,
       a8,b1,c2,d3,e4,f5,g6,h7 };

const SQUARE   Rotate135[SQUARES] =
      {a1,b8,c7,d6,e5,f4,g3,h2,
       a2,b1,c8,d7,e6,f5,g4,h3,
       a3,b2,c1,d8,e7,f6,g5,h4,
       a4,b3,c2,d1,e8,f7,g6,h5,
       a5,b4,c3,d2,e1,f8,g7,h6,
       a6,b5,c4,d3,e2,f1,g8,h7,
       a7,b6,c5,d4,e3,f2,g1,h8,
       a8,b7,c6,d5,e4,f3,g2,h1 };


>
>KarinsDad :)


Bo Persson
bop@malmo.mail.telia.com



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.