*/
char cmailMove[CMAIL_MAX_GAMES][MOVE_LEN], cmailMsg[MSG_SIZ];
-char bookOutput[MSG_SIZ*10], thinkOutput[MSG_SIZ*10], lastHint[MSG_SIZ];
+char bookOutput[MSG_SIZ*10], thinkOutput[MSG_SIZ*10], lastHint[MSG_SIZ], hintSrc;
char thinkOutput1[MSG_SIZ*10];
char promoRestrict[MSG_SIZ];
char *lastParseAttempt;
void
-ParsePV (char *pv, Boolean storeComments, Boolean atEnd)
+ParsePV (char *pv, Boolean storeComments, Boolean atEnd, int engine)
{ // Parse a string of PV moves, and append to current game, behind forwardMostMove
int fromX, fromY, toX, toY; char promoChar;
ChessMove moveType;
if(nr == 0 && !storeComments && *pv == '(') pv++; // first (ponder) move can be in parentheses
lastParseAttempt = pv;
valid = ParseOneMove(pv, endPV, &moveType, &fromX, &fromY, &toX, &toY, &promoChar);
- if(!valid && nr == 0 &&
- ParseOneMove(pv, endPV-1, &moveType, &fromX, &fromY, &toX, &toY, &promoChar)){
- nr++; moveType = Comment; // First move has been played; kludge to make sure we continue
- // Hande case where played move is different from leading PV move
+ if(!valid && nr == 0) {
+ if(engine == hintSrc && *lastHint && appData.ponderNextMove &&
+ ParseOneMove(lastHint, endPV, &moveType, &fromX, &fromY, &toX, &toY, &promoChar)){
+ // first PV move is invalid, but the engine provided hint and is probably pondering on it
+ valid++; goto append_move; // use this hint as first move
+ }
+ if(ParseOneMove(pv, endPV-1, &moveType, &fromX, &fromY, &toX, &toY, &promoChar)){
+ nr++; moveType = Comment; // PV was for previous position; kludge to make sure we continue
+ // Handle case where played move is different from leading PV move
CopyBoard(boards[endPV+1], boards[endPV-1]); // tentatively unplay last game move
CopyBoard(boards[endPV+2], boards[endPV-1]); // and play first move of PV
ApplyMove(fromX, fromY, toX, toY, promoChar, boards[endPV+2]);
parseList[endPV-1][0] = NULLCHAR;
safeStrCpy(moveList[endPV-2], "_0_0", sizeof(moveList[endPV-2])/sizeof(moveList[endPV-2][0])); // suppress premove highlight on takeback move
}
- }
+ }
+ }
pv = strstr(pv, yy_textstr) + strlen(yy_textstr); // skip what we parsed
if(nr == 0 && !storeComments && *pv == ')') pv++; // closing parenthesis of ponder move;
if(moveType == Comment && storeComments) AppendComment(endPV, yy_textstr, FALSE);
valid++; // allow comments in PV
continue;
}
+ append_move:
nr++;
if(endPV+1 > framePtr) break; // no space, truncate
if(!valid) break;
Collapse(origIndex - lineStart);
return FALSE;
}
- ParsePV(buf+startPV, FALSE, gameMode != AnalyzeMode);
+ ParsePV(buf+startPV, FALSE, gameMode != AnalyzeMode, pane+1);
*start = startPV; *end = index-1;
extendGame = (gameMode == AnalyzeMode && appData.autoExtend && origIndex - startPV < 5);
return TRUE;
int i, k=0, savedEnd=endPV, saveFMM = forwardMostMove;
*buf = NULLCHAR;
if(forwardMostMove < endPV) PushInner(forwardMostMove, endPV); // shelve PV of PV-walk
- ParsePV(pv, FALSE, 2); // this appends PV to game, suppressing any display of it
+ ParsePV(pv, FALSE, 2, 0); // this appends PV to game, suppressing any display of it
for(i = forwardMostMove; i<endPV; i++){
if(i&1) snprintf(buf+k, 10*MSG_SIZ-k, "%s ", parseList[i]);
else snprintf(buf+k, 10*MSG_SIZ-k, "%d. %s ", i/2 + 1, parseList[i]);
{ // called on right mouse click to load PV
int which = gameMode == TwoMachinesPlay && (WhiteOnMove(forwardMostMove) == (second.twoMachinesColor[0] == 'w'));
lastX = x; lastY = y;
- ParsePV(lastPV[which], FALSE, TRUE); // load the PV of the thinking engine in the boards array.
+ ParsePV(lastPV[which], FALSE, TRUE, 0); // load the PV of the thinking engine in the boards array.
extendGame = FALSE;
return TRUE;
}
}
}
hintRequested = FALSE;
- lastHint[0] = NULLCHAR;
+ lastHint[0] = NULLCHAR; hintSrc = 0;
bookRequested = FALSE;
/* Program may be pondering now */
cps->maybeThinking = TRUE;
DisplayError(buf2, 0);
}
} else {
- safeStrCpy(lastHint, buf1, sizeof(lastHint)/sizeof(lastHint[0]));
+ safeStrCpy(lastHint, buf1, sizeof(lastHint)/sizeof(lastHint[0])); hintSrc = (cps != &first) + 1;
}
return;
}
first.bookSuspend = FALSE; // [HGM] book
second.bookSuspend = FALSE;
thinkOutput[0] = NULLCHAR;
- lastHint[0] = NULLCHAR;
+ lastHint[0] = NULLCHAR; hintSrc = 0;
ClearGameInfo(&gameInfo);
gameInfo.variant = StringToVariant(appData.variant);
if(gameInfo.variant == VariantNormal && strcmp(appData.variant, "normal")) {
PushTail(currentMove, forwardMostMove); // shelve main variation. This truncates game
// kludge: use ParsePV() to append variation to game
move = currentMove;
- ParsePV(start, TRUE, TRUE);
+ ParsePV(start, TRUE, TRUE, 0);
forwardMostMove = endPV; endPV = -1; currentMove = move; // cleanup what ParsePV did
ClearPremoveHighlights();
CommentPopDown();