Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: to rotate or not?

Author: Dann Corbit

Date: 15:11:59 04/25/00

Go up one level in this thread


On April 25, 2000 at 17:24:37, Tom Kerrigan wrote:

>On April 25, 2000 at 17:15:24, Steve Maughan wrote:
>
>>Tom,
>>
>>>* Non-linked piece lists (I've discovered that linked lists are _bad_!)
>>
>>Hmmm - interesting.  Please do expand!  Surely you're not looping through all of
>>the squares?  Maybe a static array?
>>
>>Regards,
>>
>>Steve Maughan
>
>Right, I keep a static list of the pieces on the board.
>
>Linked lists are bad because they make life hard for the processor (for a number
>of reasons) and the compiler can't do any clever optimization of them.

Perhaps something along the lines of:
enum piece_type {
    PAWN=0, KNIGHT, BISHOP, ROOK, QUEEN, KING
};
enum piece_color {
    WHITE=0, BLACK
};
typedef struct tag_piece_list {
    unsigned        piece_count;
    unsigned        location[9];
    piece_type      chess_man;
    piece_color     color;
}               piece_list[] =
{
    {
        2,
        {
            0, 7
        },
        ROOK,
        WHITE
    },

    {
        2,
        {
            1, 6
        },
        KNIGHT,
        WHITE
    },
/* etc. ... */
};

And if not, why don't you like this approach?



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.