Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: to rotate or not?

Author: Tom Kerrigan

Date: 00:36:33 04/26/00

Go up one level in this thread


On April 26, 2000 at 01:25:57, Dann Corbit wrote:

>On April 25, 2000 at 23:51:10, Tom Kerrigan wrote:
>>On April 25, 2000 at 23:47:48, Tom Kerrigan wrote:
>>>On April 25, 2000 at 18:11:59, Dann Corbit wrote:
>>>>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];
>>>
>>>Looks similar to what I do, except for this. Why have 9 locations?
>>>
>>>Here's what I do:
>>>
>>>typedef struct {
>>>  BOOL dead;  // captured
>>>  int c;  // color
>>>  int t;  // type
>>>  int sq;  // square
>>>  int bit;  // 1 << type
>>>} pl_t;  // piece list type
>>>
>>>pl_t piece[2][16];
>>>int pieces[2];
>>>pl_t pawn[2][8];
>>>int pawns[2];
>>>pl_t *plp[128];  // piece list pointer
>>>
>>>-Tom
>>
>>Oh, by the way, I make sure the kings are in position 0 in the lists. That way I
>>can find them quickly.
>
>I am curious about the 'dead' flag.  Why not just delete the entry?  Is tagging
>it faster?  Are there times you delete and times that you tag?

It would be possible to copy the last entry of the list into the entry that's
being deleted. But then some pointers would have to be changed around, and then
to "revive" the piece, you would have to make a new entry at the end of the
list. So it's possible, but it's kind of a pain in the ass. I'm not sure if it's
faster or slower or what. I guess it would be faster by a bit, but not worth it
from my point of view.

This was discussed briefly a few weeks ago, and some people like to keep their
piece lists in order, so that the behavior of their move generators is more
predictable. I don't know how big a deal this is, but it is another reason to
use the dead flag.

-Tom



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.