From: H.G.Muller Date: Mon, 5 Dec 2016 12:22:40 +0000 (+0100) Subject: Implement check-count field in FENs X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=e458db4d65d5c54cccda5ee8c51659e882d9b0b4 Implement check-count field in FENs A field of the form N+M between e.p. field and ply counter is now associated with the CHECK_COUNT game state on reading and writing. It is only written when non-zero (which again should only happen in 3check). In addition a field of the form +N+M after the full-move number is recognized on reading as the SCIDB check counter, which indicates checks given. --- diff --git a/backend.c b/backend.c index ef6f839..9973c37 100644 --- a/backend.c +++ b/backend.c @@ -18467,6 +18467,12 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts) } } + i = boards[move][CHECK_COUNT]; + if(i) { + sprintf(p, "%d+%d ", i&255, i>>8); + while(*p) p++; + } + if(moveCounts) { int i = 0, j=move; @@ -18827,10 +18833,19 @@ ParseFEN (Board board, int *blackPlaysFirst, char *fen, Boolean autoSize) } } + while(*p == ' ') p++; + + board[CHECK_COUNT] = 0; // [HGM] 3check: check-count field + if(sscanf(p, "%d+%d", &i, &j) == 2) { + board[CHECK_COUNT] = i + 256*j; + while(*p && *p != ' ') p++; + } - if(sscanf(p, "%d", &i) == 1) { + c = sscanf(p, "%d%*d +%d+%d", &i, &j, &k); + if(c > 0) { FENrulePlies = i; /* 50-move ply counter */ /* (The move number is still ignored) */ + if(c == 3 && !board[CHECK_COUNT]) board[CHECK_COUNT] = (3 - j) + 256*(3 - k); // SCIDB-style check count } return TRUE;