From: H.G. Muller Date: Sun, 2 Feb 2014 13:40:16 +0000 (+0100) Subject: Detect Fischer castling in FENs X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=0d8809c4ffb488470b972032a69426b787fb9879;p=xboard.git Detect Fischer castling in FENs Castling rights with unorthodox piece placement imply Fischer castling. Make sure shuffling is done after detecting this, because it means K & R can also be shuffled (as long as K remains between both R). --- diff --git a/backend.c b/backend.c index 12ebb63..f8c277a 100644 --- a/backend.c +++ b/backend.c @@ -17897,7 +17897,6 @@ ParseFEN (Board board, int *blackPlaysFirst, char *fen, Boolean autoSize) } if(subst) return FALSE; // substitution requested, but no holdings - if(shuffle) SetUpShuffle(board, appData.defaultFrcPosition); while(*p == ' ') p++; @@ -17939,6 +17938,7 @@ ParseFEN (Board board, int *blackPlaysFirst, char *fen, Boolean autoSize) while(*p==' ') p++; if(nrCastlingRights) { + int fischer = 0; if(gameInfo.variant == VariantSChess) for(i=0; i= 'A' && *p <= 'Z' || *p >= 'a' && *p <= 'z' || *p=='-') { /* castling indicator present, so default becomes no castlings */ @@ -17969,6 +17969,7 @@ ParseFEN (Board board, int *blackPlaysFirst, char *fen, Boolean autoSize) board[CASTLING][2] = whiteKingFile; if(board[CASTLING][0] != NoRights) virgin[board[CASTLING][0]] |= VIRGIN_W; if(board[CASTLING][2] != NoRights) virgin[board[CASTLING][2]] |= VIRGIN_W; + if(whiteKingFile != BOARD_WIDTH>>1|| i != BOARD_RGHT-1) fischer = 1; break; case'Q': for(i=BOARD_LEFT; i>1|| i != BOARD_LEFT) fischer = 1; break; case'k': for(i=BOARD_RGHT-1; board[BOARD_HEIGHT-1][i]!=BlackRook && i>blackKingFile; i--); @@ -17983,6 +17985,7 @@ ParseFEN (Board board, int *blackPlaysFirst, char *fen, Boolean autoSize) board[CASTLING][5] = blackKingFile; if(board[CASTLING][3] != NoRights) virgin[board[CASTLING][3]] |= VIRGIN_B; if(board[CASTLING][5] != NoRights) virgin[board[CASTLING][5]] |= VIRGIN_B; + if(blackKingFile != BOARD_WIDTH>>1|| i != BOARD_RGHT-1) fischer = 1; break; case'q': for(i=BOARD_LEFT; i>1|| i != BOARD_LEFT) fischer = 1; case '-': break; default: /* FRC castlings */ @@ -18025,6 +18029,7 @@ ParseFEN (Board board, int *blackPlaysFirst, char *fen, Boolean autoSize) if(board[CASTLING][i] != NoRights) initialRights[i] = board[CASTLING][i]; if(gameInfo.variant == VariantSChess) for(i=0; i