Thread View: gnu.chess
1 messages
1 total messages
Started by Brian Wong
Sat, 19 May 1990 08:59
GNUCHESS 3.0 question
Author: Brian Wong
Date: Sat, 19 May 1990 08:59
Date: Sat, 19 May 1990 08:59
68 lines
2623 bytes
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
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