Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: questions about undoing moves

Author: Tom Kerrigan

Date: 16:58:01 04/23/00

Go up one level in this thread


On April 23, 2000 at 17:13:35, John Coffey wrote:

>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.

I encode moves into an integer.

Bits 1-7 are for the square that a piece is moving from, bits 8-14 are for the
square it's moving to, and bits 15-17 are for the piece that it's being promoted
to (as necessary).

Here's the structure that I use to take back moves:

typedef struct {
  int move;
  pl_t *cap;
  int castle;
  int ep;
  int fifty;
} undo_t;

"cap" is a pointer into my piece list; it's the piece that was captured, if any.

>My board consists of 64 pointers.  Each pointer points to a stack of square

I used to do this, and recently discovered that it isn't such a hot approach.
The extra indirection really slows things down.

-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.