🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.chess
Article #6206

GNUCHESS 3.0 question

#6206
From: Brian Wong
Date: Sat, 19 May 1990 08:59
68 lines
2623 bytes
Hi, I found a problem with GNUCHESS 3.0.
I was playing a game on a PS/2 when the program
crashed during the following endgame.

  |----|----|----|----|----|----|----|----|
8 |    |    |    |    |    |    | *K |    |		BLACK'S MOVE
  +----+----+----+----+----+----+----+----+
7 |    |    |    |    |  R |    |    |  P |
  +----+----+----+----+----+----+----+----+
6 |    |    |    |    |    |    |    |    |
  +----+----+----+----+----+----+----+----+
5 |    |    |    |    |    |    |  K |    |
  +----+----+----+----+----+----+----+----+
4 |    |    |    |    |    |    |    |    |
  +----+----+----+----+----+----+----+----+
3 |    |    |    |    |    |    |    |    |
  +----+----+----+----+----+----+----+----+
2 |    |    |    |    |    |    |    |    |
  +----+----+----+----+----+----+----+----+
1 |    |    |    |    |    |    |    |    |
  |----|----|----|----|----|----|----|----|
    a    b    c    d    e    f    g    h

The program crashed at line C because at line A, whenever row(sq) == 7
(i.e. 63 <= sq <= 56) adding 8 to sq will make sq go over the array bound.
Similar kind of scenerio at line B will also make sq go below the array bound.

int ScoreKPK(side, winner, loser, king1, king2, sq)
{
    .
    .
    .
    if (winner == white) {
        .
        .
        .
        if (row(sq) < 6)	/* line A */
            sq += 16;
        else
            sq += 8;
    }
    else {
        .
        .
        .
        if (row(sq) > 1)	/* line B */
            sq -= 16;
        else
            sq -= 8;
    }
    s += 8 * (taxicab(king2, sq) - taxicab(king1, sq)); /* line C */
	/* taxicab(i,j) == taxidata[i][j] where
		taxidata is declared as taxidata[64][64] */
    return (s);
}

My question is: are the following changes correct??

	line A:				line B:

        if (row(sq) < 6)		if (row(sq) > 1)
            sq += 16;			    sq -= 16;
        else if (row(sq) == 6)		else if (row(sq) == 1)
            sq += 8;			    sq -= 8;

Thanks,
Brian
Technical Details
Message-ID: <1990May19.085941.10552@cs.UAlberta.CA>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!alberta!wong

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d71d,e6aa8adc14b4786b,start
X-Google-Attributes: gid10d71d,public
X-Google-ArrivalTime: 1990-05-19 04:45:51 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!alberta!wong
From: wong@cs.UAlberta.CA (Brian Wong)
Newsgroups: gnu.chess
Subject: GNUCHESS 3.0 question
Keywords: problem in ScoreKPK()
Message-ID: <1990May19.085941.10552@cs.UAlberta.CA>
Date: 19 May 90 08:59:41 GMT
Organization: University of Alberta, Edmonton, Alberta, Canada
Lines: 68
Posted: Sat May 19 09:59:41 1990