Author: KarinsDad
Date: 14:17:47 05/11/99
Go up one level in this thread
On May 11, 1999 at 16:44:30, Bo Persson wrote:
>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. :-)
>
Actually, I have no clue as to whether I am rotating them 45 or -45 or 135 or
whatever. These are just the names I used (BitBoard, BitBoard45, BitBoard90, and
BitBoard135). I just create them and then use the same mechanism to access them
(I sometimes just go on gut feel when it comes to programming).
I noticed that a lot of people use terms such as Northwest or Southwest when
accessing their rotated bitboards and I think, "Gee, that would have made the
reading of the code easier.".
>[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 };
>
>
Since I have wasted space in my 16 byte arrays at this point, I am referencing
them via row and column (in fact, a lot of things are accessed in my program
that way). This is especially useful for the non-rotated bitboards, but I will
think about it more later when I am optimizing and converting the rotated
bitboards to 8 bytes each. A lot of my row and column code is set up so that
they can be put into registers later and re-used within a given code segment, so
I'm wondering if keeping it the way it is will be faster than a table lookup.
But now that you have shown me a different way, I will try out both (it does
take time to get the row and column, however, I often use them for multiple
things in the same section of code). Thanks.
KarinsDad :)
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.