🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.chess
Article #4896

Patch to pl70 to fix moving after mate

#4896
From: Tim Mann
Date: Mon, 13 Jun 1994 20:27
102 lines
4007 bytes
The following patch fixes the bug where GNU Chess pl70 would not realize the
game was over when it was checkmated or stalemated, and would therefore try to
make another move.  It's mostly due to Chua Kong Sian, but I helped a little.

The patch also contains a small change to the handling of history[] from Kong
Sian.  It is the very last section of the patch.

	--Tim


*** search.c.orig	Tue May 10 05:44:23 1994
--- search.c	Wed Jun  1 16:11:02 1994
***************
*** 451,457 ****
      return;
  #include "debug4.h"
      /* if no moves and not in check then draw */
!   if ((score == -9998) && !(SqAtakd (PieceList[side][0], xside)))
      {
        root->flags |= draw;
        DRAW = CP[87];		/* No moves */
--- 451,457 ----
      return;
  #include "debug4.h"
      /* if no moves and not in check then draw */
!   if ((score == -9999) && !(SqAtakd (PieceList[side][0], xside)))
      {
        root->flags |= draw;
        DRAW = CP[87];		/* No moves */
***************
*** 467,473 ****
  
     algbr (root->f, root->t, (SHORT) root->flags);
    /* if not mate or draw make move and output it */
!   if (((score != -9998)  && (score != 9998) && (rpt <= 2)) || (root->flags & draw))
      {
        MakeMove (side, &Tree[0], &tempb, &tempc, &tempsf, &tempst, &INCscore);
  #if !defined NOMATERIAL
--- 467,473 ----
  
    algbr (root->f, root->t, (SHORT) root->flags);
    /* if not mate or draw make move and output it */
!   if (((score != -9999)  && (score != 9998) && (rpt <= 2)) || (root->flags & draw))
      {
        MakeMove (side, &Tree[0], &tempb, &tempc, &tempsf, &tempst, &INCscore);
  #if !defined NOMATERIAL
***************
*** 491,498 ****
    if (g->flags & capture && g->piece == king) { flag.mate = flag.illegal = true; }
    /* If Time Control get the elapsed time */
    if (TCflag) ElapsedTime (1);
    /* if mate set flag */
!   if ((score == -9998) || (score == 9998)) {flag.mate = true; 
  #ifndef CLIENT
  	flag.quit = true;
  #endif
--- 491,501 ----
    if (g->flags & capture && g->piece == king) { flag.mate = flag.illegal = true; }
    /* If Time Control get the elapsed time */
    if (TCflag) ElapsedTime (1);
+   /* Don't make a bogus move after we're mated or stalemated --TPM */
+   if (score == -9999)
+     mvstr[0][0] = mvstr[1][0] = mvstr[2][0] = mvstr[3][0] = mvstr[4][0] = '\0';
    /* if mate set flag */
!   if ((score == -9999) || (score == 9998)) {flag.mate = true; 
  #ifndef CLIENT
  	flag.quit = true;
  #endif
***************
*** 752,758 ****
   */
  
  #if defined ttblsz
! 	  if ( flag.hash)
  	    {
  		if (ProbeTTable (side, depth, ply, &alpha, &beta, &score) == true)
  		  {
--- 755,761 ----
   */
  
  #if defined ttblsz
! 	  if ( flag.hash && ply > 1)
  	    {
  		if (ProbeTTable (side, depth, ply, &alpha, &beta, &score) == true)
  		  {
***************
*** 1210,1216 ****
        if (side == black)
  	j |= 0x4000;
        if (history[j] < HISTORYLIM)
! 	history[j] += (unsigned short) 1 << depth;
  #endif
        if (node->t != (SHORT) (GameList[GameCnt].gmove & 0xFF))
  	if (best <= beta)
--- 1213,1219 ----
        if (side == black)
  	j |= 0x4000;
        if (history[j] < HISTORYLIM)
! 	history[j] |= (unsigned short) 1 << depth;
  #endif
        if (node->t != (SHORT) (GameList[GameCnt].gmove & 0xFF))
  	if (best <= beta)
Technical Details
Message-ID: <2tifg3$7h0@src-news.pa.dec.com>
Path: arc1-ca.pugleaf.net!nntp.gmd.de!Germany.EU.net!EU.net!uunet!MathWorks.Com!yeshua.marcam.com!charnel.ecst.csuchico.edu!olivea!decwrl!pa.dec.com!src.dec.com!mann

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d71d,bdfb20acf7b23611,start
X-Google-Attributes: gid10d71d,public
X-Google-ArrivalTime: 1994-06-13 13:50:13 PST
Path: arc1-ca.pugleaf.net!nntp.gmd.de!Germany.EU.net!EU.net!uunet!MathWorks.Com!yeshua.marcam.com!charnel.ecst.csuchico.edu!olivea!decwrl!pa.dec.com!src.dec.com!mann
From: mann@src.dec.com (Tim Mann)
Newsgroups: gnu.chess
Subject: Patch to pl70 to fix moving after mate
Date: 13 Jun 1994 20:27:47 GMT
Organization: DEC Systems Research Center
Lines: 104
Message-ID: <2tifg3$7h0@src-news.pa.dec.com>
NNTP-Posting-Host: cypress.pa.dec.com