Well, it sure looks like a bug, if you are absolutely certain that the ruling referred to this digram. I cannot spot an error in the code, though:
- Code: Select all
/* [HGM] bare: don't allow bare King to win */
if((gameInfo.holdingsWidth == 0 || gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat)
&& result != GameIsDrawn)
{ int i, j, k=0, color = (result==WhiteWins ? (int)WhitePawn : (int)BlackPawn);
for(j=BOARD_LEFT; j<BOARD_RGHT; j++) for(i=0; i<BOARD_HEIGHT; i++) {
int p = (int)boards[forwardMostMove][i][j] - color;
if(p >= 0 && p <= (int)WhiteKing) k++;
}
if (appData.debugMode) {
fprintf(debugFP, "GE(%d, %s, %d) bare king k=%d color=%d\n",
result, resultDetails ? resultDetails : "(null)", whosays, k, color);
}
if(k <= 1) {
result = GameIsDrawn;
sprintf(buf, "%s but bare king", resultDetails);
resultDetails = buf;
}
}
I simply count the number of pieces of the winning side that is between Pawn and King (which should be all pieces), and if it is one, it must be a bare King. Perhaps I am counting on the wrong board here. I guess the clock interrupt causing the forfit ust have come between incrementing the move number and pressing the clock for that move, before the board was fully copied.
Indeed, the MakeMove() routine starts incrementing forwardMostMove, then does SwitchClock(), and only then copies the board. Between forwardMostMove++; and SwitchClocks(); there are only two if() statements, both with false conditions in your case. (One testing if there are more than 500 moves, making the game history overflow, the other a hack for broadcasting the game with my ChessLive! viewer.) So there must be only an extremely short time between them.
But to be absolutely safe I should put the forwardMostMov++; behind updating the board. Yegh. That means I have to replace it by forwardMostMove+1 everywhere in between. And it is used quite often...