Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: bitboard vs 0x88 again?

Author: Omid David Tabibi

Date: 17:40:37 10/08/03

Go up one level in this thread


On October 08, 2003 at 20:26:04, Uri Blass wrote:

>On October 08, 2003 at 19:29:05, Omid David Tabibi wrote:
>
>>On October 08, 2003 at 09:51:01, Robert Hyatt wrote:
>>
>>>On October 08, 2003 at 06:33:00, Sune Fischer wrote:
>>>
>>>>On October 07, 2003 at 20:19:00, Russell Reagan wrote:
>>>>
>>>>>>I'm sure you could make use of that 8x8 array to implement non-bitboard
>>>>>>functions where appropriate and use the bitboard ones where they're more
>>>>>>convenient, taking advantage of both approaches; I don't know why this has to be
>>>>>>regarded as a dichotomy!
>>>>>
>>>>>Unfortunately many of the advantages of 0x88-like systems cannot be taken
>>>>>advantage of using a 64-element array.
>>>>
>>>>What are the many advantages of 0x88-like systems?
>>>
>>>The most important are "is square xxx on the same diagonal as square yyy"
>>>along with "is square xxx off the edge of the real board?"
>>>
>>>There are similar questions easier to answer with bitboards.
>>
>>I use a simple board[64] representation. No bitboard, no 0x88...
>
>same for me.
>
>
>If you have a
>>handy attack table, the board representation is insignificant. When using
>>bitboard, you get the attack table built-in, using other methods you have to
>>write your own attack table (I use 32 bit per square).
>>
>>In a simple board[64], you can check a square's diagonal by:
>>
>>#define DIAG1(x)    (((x) >> 3) + ((x) & 7))          // y = x diag
>>#define DIAG2(x)    (((x) >> 3) + (((x) & 7) ^ 7))    // y = -x diag
>
>I have it only for rank and files.
>The question is when this information about diagnols can help me.

BOOL attacks(int from, int to) {
    int offset;
    switch (piece[from]) {
    case BISHOP:
        if (DIAG1(from) == DIAG1(to) {
            offset = ...;
            break;
        }
        if (DIAG2(from) == DIAG2(to) {
            offset = ...;
            break;
        }
        return FALSE;
    case ROOK:
        if (COL(from) == COL(to) {
            offset = ...;
            break;
        }
        if (ROW(from) == ROW(to) {
            offset = ...;
            break;
        }
        return FALSE;
    case QUEEN:
        if (DIAG1(from) == DIAG1(to) {
            offset = ...;
            break;
        }
        if (DIAG2(from) == DIAG2(to) {
            offset = ...;
            break;
        }
        if (COL(from) == COL(to) {
            offset = ...;
            break;
        }
        if (ROW(from) == ROW(to) {
            offset = ...;
            break;
        }
        return FALSE;
    case KING:
        return (abs(COL(to) - COL(from)) <= 1 && abs(ROW(to) - ROW(from)) <= 1);
    case KNIGHT:
        return (...);
    }

    // use the calculated 'offset' and scan from source to target squares
    ...
}

This is just one possible use of these macros. Of course you will not need this
if you have attack tables.


>
>Maybe it already can help me in things that I do but I do not think about them
>in this moment.
>
>I use in some cases the array direction[64][64] that gives different number for
>different directions(include queen and knight directions).
>
>>
>>But I don't use the above anymore. Attack tables give the needed data.
>>
>>And checking whether a square is off the edge of the board can be very easy
>>using a "mailbox":
>>
>>const int mailbox[] = {
>>    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
>>    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
>>    -1,  0,  1,  2,  3,  4,  5,  6,  7, -1,
>>    -1,  8,  9, 10, 11, 12, 13, 14, 15, -1,
>>    -1, 16, 17, 18, 19, 20, 21, 22, 23, -1,
>>    -1, 24, 25, 26, 27, 28, 29, 30, 31, -1,
>>    -1, 32, 33, 34, 35, 36, 37, 38, 39, -1,
>>    -1, 40, 41, 42, 43, 44, 45, 46, 47, -1,
>>    -1, 48, 49, 50, 51, 52, 53, 54, 55, -1,
>>    -1, 56, 57, 58, 59, 60, 61, 62, 63, -1,
>>    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
>>    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
>>};
>>
>>And address the above table using:
>>
>>const int mailbox64[64] = {
>>    21, 22, 23, 24, 25, 26, 27, 28,
>>    31, 32, 33, 34, 35, 36, 37, 38,
>>    41, 42, 43, 44, 45, 46, 47, 48,
>>    51, 52, 53, 54, 55, 56, 57, 58,
>>    61, 62, 63, 64, 65, 66, 67, 68,
>>    71, 72, 73, 74, 75, 76, 77, 78,
>>    81, 82, 83, 84, 85, 86, 87, 88,
>>    91, 92, 93, 94, 95, 96, 97, 98,
>>};
>
>I do not have these arrays and I have some arrays like leftdown[sq](usually sq-9
>but can be -1 in case that sq-9 is not in the same diagnol).
>
>I do not understand why mailbox and mailbox64 are better than arrays like
>leftdown[64].
>
>
>>
>>Using bitboards is a matter of taste. I personally don't like bitboards because
>>it is not easy to extract the data you need for the evaluation function. Of
>>course people like you and Gerd who "think bitboard" can find nice tricks to
>>handle those issues, but still extracting data out of board[64], color[64] is
>>easier :)
>
>I have info[64] that include both color and piece and I get the color or the
>piece by defines.
>
>Uri



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.