Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Programming piece table

Author: Dan Newman

Date: 11:38:24 04/18/98

Go up one level in this thread


On April 18, 1998 at 00:10:15, Robert Hyatt wrote:

>On April 17, 1998 at 15:46:23, Dan Newman wrote:
>
<snip>
>>1) When a piece is captured (and removed from the piece list (figure
>>list))
>>   move the piece at the end of the list into the now empty location.
>>   When undoing the capture just put the un-captured piece at the end of
>>   the list.  You would of course maintain a count of the pieces in each
>>   list to make it easy to find the ends of the lists and for iteration
>>   through the lists.
>>
>>2) Use one of the bits in the piece to mark the piece as captured but do
>>   not remove the piece from the list.  Use this bit to skip over this
>>   piece when doing move generation, etc.  When undoing the capture,
>>just
>>   clear this bit.  (You could use the high order bit in the 'what'
>>   member of the piece.)
>>
>
>
>
>here's something we did in Cray Blitz:  on the normal board, put a
>pointer
>to the piece "record" you defined above.  then you can always find out
>which piece record to "fix" since after making a move "to" points to
>board[to] which points to the piece record for the piece on that
>square...
>


Yes, that's an innovation I didn't think to include in the
above.  My first chess engine used piece list
indices in the board to find the piece record.  I also used
the swapping trick which requires an update to those
indices--rather ugly code but once debugged, ok.  I now
use a board which is just an array of pointers to piece.
This makes it very simple to move pieces on the board and
seems to work fairly well (performance-wise) on my PC.
(At one point even my piece lists were arrays of pointers
to piece to make the lists easy to contract or reorder.
This made some sense because the pieces were rather heavy
weight structures.  Currently they are a fairly heavy 48
bytes and are stored in linked lists.)

-Dan.




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.