Computer Chess Club Archives


Search

Terms

Messages

Subject: questions about undoing moves

Author: John Coffey

Date: 14:13:35 04/23/00


Now that I have actually started writting my dream program :-),
I have quite a few questions.  I will start with undoing moves ...

I wrote a program in 1987 that undid moves during the search by keeping
a pointer to the destination square, and the original square and the previous
value of each.  These 4 values were kept in an undo stack, and I would read
the last entry every time I needed to back up a move.

This seems reasonable but cumbersome.

My new board has 16 bytes per square because each square is being evaluated
for positional considerations.  If I want to undo these moves then I have to
copy and restore more information.   I wasn't sure how this would impact the
speed of the program.  Maybe it wouldn't have any impact at all but then again
maybe it would.

So in my current program I use what is perhaps an overly elaboarate data
structure.   I might choose to abandon it, but wanted to get the ideas of
others.

My board consists of 64 pointers.  Each pointer points to a stack of square
data.  So if I have 32 squares in a stack * 16 bytes each *64 squares then
I have a pretty big data structure.  The advantage of this method is that
I can copy my square data easily when I want to go deeper into the program ...

*(ptr+1)=*ptr;
ptr++;
(modify new data here.)

Then when I want to undo a move it is just ....

ptr--;

but I still have to keep track of all the affected squares.


I see a possible disadvantage to this approach in that now I have an extra
level of indirection for accessing the squares on my board.  This is why I
am considering abandoning the approach.

John



This page took 0.01 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.