parse, currentMove);
if (sscanf(parse, " game %d", &gamenum) == 1) {
if(gamenum == ics_gamenum) { // [HGM] bughouse: old code if part of foreground game
+ new_piece[0] = NULLCHAR;
+ sscanf(parse, "game %d white [%s black [%s <- %s",
+ &gamenum, white_holding, black_holding,
+ new_piece);
+ white_holding[strlen(white_holding)-1] = NULLCHAR;
+ black_holding[strlen(black_holding)-1] = NULLCHAR;
if (gameInfo.variant == VariantNormal) {
/* [HGM] We seem to switch variant during a game!
* Presumably no holdings were displayed, so we have
switch(gameInfo.boardWidth) { // base guess on board width
case 9: newVariant = VariantShogi; break;
case 10: newVariant = VariantGreat; break;
- default: newVariant = VariantCrazyhouse; break;
+ default: newVariant = VariantCrazyhouse;
+ if(strchr(white_holding, 'E') || strchr(black_holding, 'E') ||
+ strchr(white_holding, 'H') || strchr(black_holding, 'H') )
+ newVariant = VariantSChess;
}
VariantSwitch(boards[currentMove], newVariant); /* temp guess */
/* Get a move list just to see the header, which
SendToICS(str);
}
}
- new_piece[0] = NULLCHAR;
- sscanf(parse, "game %d white [%s black [%s <- %s",
- &gamenum, white_holding, black_holding,
- new_piece);
- white_holding[strlen(white_holding)-1] = NULLCHAR;
- black_holding[strlen(black_holding)-1] = NULLCHAR;
/* [HGM] copy holdings to board holdings area */
CopyHoldings(boards[forwardMostMove], white_holding, WhitePawn);
CopyHoldings(boards[forwardMostMove], black_holding, BlackPawn);
fromY = moveList[move - 1][1] - ONE;
toX = moveList[move - 1][2] - AAA;
toY = moveList[move - 1][3] - ONE;
- if (fromY == (whiteToPlay ? BOARD_HEIGHT-2 : 1) &&
- toY == (whiteToPlay ? BOARD_HEIGHT-4 : 3) &&
- boards[move][toY][toX] == (whiteToPlay ? BlackPawn : WhitePawn) &&
- fromX == toX) {
+ if ((whiteToPlay ? toY < fromY - 1 : toY > fromY + 1) &&
+ boards[move][toY][toX] == (whiteToPlay ? BlackPawn : WhitePawn) ) {
/* 2-square pawn move just happened */
- *p++ = toX + AAA;
- *p++ = whiteToPlay ? '6'+BOARD_HEIGHT-8 : '3';
+ *p++ = (3*toX + 5*fromX + 4)/8 + AAA;
+ *p++ = (3*toY + 5*fromY + 4)/8 + ONE;
+ if(gameInfo.variant == VariantBerolina) {
+ *p++ = toX + AAA;
+ *p++ = toY + ONE;
+ }
} else {
*p++ = '-';
}
if(*p=='-') {
p++; board[EP_STATUS] = EP_NONE;
} else {
- char c = *p++ - AAA;
-
- if(c < BOARD_LEFT || c >= BOARD_RGHT) return TRUE;
- if(*p >= '0' && *p <='9') p++;
- board[EP_STATUS] = c;
+ int d, r, c = *p - AAA;
+
+ if(c >= BOARD_LEFT && c < BOARD_RGHT) {
+ p++;
+ board[EP_STATUS] = board[EP_FILE] = c; r = 0;
+ if(*p >= '0' && *p <='9') r = board[EP_RANK] = *p++ - ONE;
+ d = (r < BOARD_HEIGHT << 1 ? 1 : -1); // assume double-push (P next to e.p. square nearer center)
+ if(board[r+d][c] == EmptySquare) d *= 2; // but if no Pawn there, triple push
+ board[LAST_TO] = 256*(r + d) + c;
+ c = *p++ - AAA;
+ if(c >= BOARD_LEFT && c < BOARD_RGHT) { // mover explicitly mentioned
+ if(*p >= '0' && *p <='9') r = board[EP_RANK] = *p++ - ONE;
+ board[LAST_TO] = 256*r + c;
+ if(!(board[EP_RANK]-r & 1)) board[EP_RANK] |= 128;
+ }
+ }
}
}