Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Programming piece table

Author: Heiner Marxen

Date: 12:15:06 04/17/98

Go up one level in this thread


On April 17, 1998 at 07:30:51, Inmann Werner wrote:

>Piece table question
>
>Can anybody help me?
>
>When generating moves in my chess programm, until now I search the whole
>boad for pieces. I want to speed this up and use a figure list like
>this:
>
>Typedef struct{
>	Char where	      /*Position on Table*/
>	Char what             /*which piece (0=nothing;1=pawn ...*/
>	}TYPFIGLI;
>
>TYPFIGLI FIGLI[2][16];       (FIGLI[0].. is white, FIGLI[1].. is black)
>
>Char FIGBR[125(A board table with a 'pointer' to FIGLI (10*12 board))
>
>In the move Generator and the evaluation function, everything works
>fine.
>In the routine 'DO_MOVE' it is a little bit tricky, but it works.
>	FIGLI[color][FIGBR[from]].where=tomove
>        FIGBR[tomove]=FIGBR[from]
>        FIGBR[from]=-1

Wait a minute... you want to scan (16 elements of) FIGLI instead of
(64 elements of) FIGBR in order to enumerate the pieces of the side
to move, right?
Hence, the beaten piece must be "deleted" somehow from the FIGLI,
to avoid finding it as a candidate for move generation.

>But in the routine 'UNDO_MOVE' i have a problem, when I put back a
>captured piece.

In the same way as you remember *what* has been beaten, you should
remember
*which slot* in FIGLI it did occupy.  While the piece is beaten, the
slot
could be marked as "unused" and is skipped when scanning FIGLI.

>There are two possibilities.
>
>1) search the structure FIGLI for an empty field and use it.
>2) Increase the number of pieces in FIGLI and store the piece in the
>last one
>
>If I use 1), I possibly have to search up to 16 times to find an emty
>location.
>If I use 2), I have to increase the structure of FIGLI and more and more
>'pieces' are in it. In 'Generate moves'	everything slows down. (maybe I
>get even an overflow).
>
>Which possibility is better?(I think the first one)
>Does anybody know anything much better and faster!!!.

What I sketched above looks like a third way to do it, without any
searches.

>Thank you very much,
>
>INMANN WERNER
>
>PS: I am from Germany, and my English is rather poor. Excuse me!!

You are welcome!  Your English was good enough for me :-)



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.