🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Tom Vijlbrief Tue, 23 Jan 1990 07:58
Gnuchess does not undo promotion correctly & fix
#72
Author: Tom Vijlbrief
Date: Tue, 23 Jan 1990 07:58
70 lines
2563 bytes
The routine Undo() in gnuchess 1.52 (I don't have the newer version 1.55)
does not correctly undo a pawn promotion. Undo() is in nondsp.c and uxdsp.c.

The original version is:
======================================================================
Undo()
 
/*
   Undo the most recent half-move.
*/
 
{
short f,t;
  f = GameList[GameCnt].gmove>>8;
  t = GameList[GameCnt].gmove & 0xFF;
  if (board[t] == king && distance(t,f) > 1)
    castle(GameList[GameCnt].color,f,t,2);
  else
    {
      board[f] = board[t]; color[f] = color[t];
      board[t] = GameList[GameCnt].piece;
      color[t] = GameList[GameCnt].color;
      if (board[f] == king) --kingmoved[color[f]];
    }
  if (TCflag) ++TimeControl.moves[color[f]];
  GameCnt--; mate = false; Sdepth = 0;
  UpdateDisplay(0,0,1,0);
  InitializeStats();
}
==================================================
The fixed version is:
=================================================

......

{
short f,t;
  f = GameList[GameCnt].gmove>>8;
  t = GameList[GameCnt].gmove & 0xFF;
  if (board[t] == king && distance(t,f) > 1)
    castle(GameList[GameCnt].color,f,t,2);
  else
    {
      /* Check for promotion: */
      if (board[t] == queen &&
        ((row[f]==6 && row[t]==7) || (row[f]==1 && row[t]==0))) {
          int g, from= f;
          for (g= GameCnt-1; g>=0; g--)
            if (GameList[g].gmove & 0xFF == from)
                from= GameList[g].gmove>>8;
          if (row[from]==1 || row[from]==6)
                board[t]= pawn;
      }

      board[f] = board[t]; color[f] = color[t];
      board[t] = GameList[GameCnt].piece;
      color[t] = GameList[GameCnt].color;
      if (board[f] == king) --kingmoved[color[f]];
    }

.... etc ....
======================================================

===============================================================================
Tom Vijlbrief
TNO Institute for Perception
P.O. Box 23				Phone: +31 34 63 562 11
3769 ZG  Soesterberg			E-mail: tnosoes!tom@mcvax.cwi.nl
The Netherlands				    or:	uunet!mcvax!tnosoes!tom
===============================================================================
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads