{
int n = 0;
if(!*escapes) return strlen(s);
- while(*s) n += (*s != ':' && !strchr(escapes, *s)), s++;
+ while(*s) n += (*s != '/' && !strchr(escapes, *s)), s++;
return n;
}
/* [HGM] moved here from winboard.c because of its general usefulness */
/* Basically a safe strcpy that uses the last character as King */
{
- int result = FALSE; int NrPieces;
+ int result = FALSE; int NrPieces, offs;
if( map != NULL && (NrPieces=ptclen(map, escapes)) <= (int) EmptySquare
&& NrPieces >= 12 && !(NrPieces&1)) {
int i, j = 0; /* [HGM] Accept even length from 12 to 88 */
for( i=0; i<(int) EmptySquare; i++ ) table[i] = '.';
- for( i=0; i<NrPieces/2-1; i++ ) {
+ for( i=offs=0; i<NrPieces/2-1; i++ ) {
char *p;
- if(map[j] == ':' && *escapes) i = CHUPROMOTED WhitePawn, j++;
- table[i] = map[j++];
- if(p = strchr(escapes, map[j])) j++, table[i] += 64*(p - escapes + 1);
+ if(map[j] == '/' && *escapes) offs = WhiteTokin - i, j++;
+ table[i + offs] = map[j++];
+ if(p = strchr(escapes, map[j])) j++, table[i + offs] += 64*(p - escapes + 1);
}
table[(int) WhiteKing] = map[j++];
- for( i=0; i<NrPieces/2-1; i++ ) {
+ for( i=offs=0; i<NrPieces/2-1; i++ ) {
char *p;
- if(map[j] == ':' && *escapes) i = CHUPROMOTED WhitePawn, j++;
- table[WHITE_TO_BLACK i] = map[j++];
- if(p = strchr(escapes, map[j])) j++, table[WHITE_TO_BLACK i] += 64*(p - escapes + 1);
+ if(map[j] == '/' && *escapes) offs = WhiteTokin - i, j++;
+ table[WHITE_TO_BLACK i + offs] = map[j++];
+ if(p = strchr(escapes, map[j])) j++, table[WHITE_TO_BLACK i + offs] += 64*(p - escapes + 1);
}
table[(int) BlackKing] = map[j++];
gameInfo.boardWidth = 12;
gameInfo.boardHeight = 12;
nrCastlingRights = 0;
- SetCharTableEsc(pieceToChar, "P.BRQSEXOGCATHD.VMLIFN:+.++.++++++++++.+++++K"
- "p.brqsexogcathd.vmlifn:+.++.++++++++++.+++++k", SUFFIXES);
+ SetCharTableEsc(pieceToChar, "P.BRQSEXOGCATHD.VMLIFN/+.++.++++++++++.+++++K"
+ "p.brqsexogcathd.vmlifn/+.++.++++++++++.+++++k", SUFFIXES);
break;
case VariantCourier:
pieces = CourierArray;
// most tests only when we understand the game, i.e. legality-checking on
if( appData.testLegality )
{ /* [HGM] Some more adjudications for obstinate engines */
- int nrW, nrB, bishopColor, staleW, staleB, nr[EmptySquare+1], i;
+ int nrW, nrB, bishopColor, staleW, staleB, nr[EmptySquare+2], i;
static int moveCount = 6;
ChessMove result;
char *reason = NULL;
}
if(sscanf(message, "piece %s %s", buf2, buf1) == 2) {
ChessSquare piece = WhitePawn;
- char *p=buf2, *q, *s = SUFFIXES, ID = *p;
+ char *p=message+6, *q, *s = SUFFIXES, ID = *p;
if(*p == '+') piece = CHUPROMOTED WhitePawn, ID = *++p;
if(q = strchr(s, p[1])) ID += 64*(q - s + 1), p++;
piece += CharToPiece(ID & 255) - WhitePawn;
&& gameInfo.variant != VariantLosers && gameInfo.variant != VariantGiveaway
&& gameInfo.variant != VariantSuicide // [HGM] losers: except in losers, of course...
&& result != GameIsDrawn)
- { int i, j, k=0, color = (result==WhiteWins ? (int)WhitePawn : (int)BlackPawn);
+ { int i, j, k=0, oppoKings = 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 = (signed char)boards[forwardMostMove][i][j] - color;
if(p >= 0 && p <= (int)WhiteKing) k++;
+ oppoKings += (p + color == WhiteKing + BlackPawn - color);
}
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) {
+ if(k <= 1 && oppoKings > 0) { // the latter needed in Atomic, where bare K wins if opponent King already destroyed
result = GameIsDrawn;
snprintf(buf, MSG_SIZ, "%s but bare king", resultDetails);
resultDetails = buf;
int i, j, k, w=0, subst=0, shuffle=0, wKingRank = -1, bKingRank = -1;
char *p, c;
int emptycount, virgin[BOARD_FILES];
- ChessSquare piece;
+ ChessSquare piece, king = (gameInfo.variant == VariantKnightmate ? WhiteUnicorn : WhiteKing);
p = fen;
p++;
}
board[i][(j++)+gameInfo.holdingsWidth] = piece;
- if(piece == WhiteKing) wKingRank = i;
- if(piece == BlackKing) bKingRank = i;
+ if(piece == king) wKingRank = i;
+ if(piece == WHITE_TO_BLACK king) bKingRank = i;
} else {
return FALSE;
}