X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=c6112e3e9acaccb5364aaa0b487d850dce9622a5;hb=a009a27e8c1e0bfa818f12fdcae675d0babc510a;hp=7f9b6642ed7915bc7dd8b0b9cf0abebd18e9c86a;hpb=49ff2afc84db668b0f58cc3c6f785fc1942039a9;p=xboard.git diff --git a/backend.c b/backend.c index 7f9b664..c6112e3 100644 --- a/backend.c +++ b/backend.c @@ -5,7 +5,7 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -224,6 +224,7 @@ FILE *WriteTourneyFile P((char *results, FILE *f)); void DisplayTwoMachinesTitle P(()); static void ExcludeClick P((int index)); void ToggleSecond P((void)); +void PauseEngine P((ChessProgramState *cps)); #ifdef WIN32 extern void ConsoleCreate(); @@ -5415,7 +5416,8 @@ ParsePV (char *pv, Boolean storeComments, Boolean atEnd) Boolean valid; int nr = 0; - if (gameMode == AnalyzeMode && currentMove < forwardMostMove) { + lastParseAttempt = pv; if(!*pv) return; // turns out we crash when we parse an empty PV + if ((gameMode == AnalyzeMode || gameMode == AnalyzeFile) && currentMove < forwardMostMove) { PushInner(currentMove, forwardMostMove); // [HGM] engine might not be thinking on forwardMost position! pushed = TRUE; } @@ -5520,7 +5522,7 @@ PvToSAN (char *pv) static char buf[10*MSG_SIZ]; int i, k=0, savedEnd=endPV, saveFMM = forwardMostMove; *buf = NULLCHAR; - if(forwardMostMove < endPV) PushInner(forwardMostMove, endPV); + 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 for(i = forwardMostMove; i 16; // KCKAA, KCKAX, KCKEEX, KCKEXX (XX!=HH), KCKXXX // TO DO: cases wih an unpromoted f-Pawn acting as platform for an opponent Cannon + } else if(v == VariantKnightmate) { + if(nMine == 1) return FALSE; + if(nMine == 2 && nHis == 1 && pCnt[WhiteBishop+side] + pCnt[WhiteFerz+side] + pCnt[WhiteKnight+side]) return FALSE; // KBK is only draw } else if(pCnt[WhiteKing] == 1 && pCnt[BlackKing] == 1) { // other variants with orthodox Kings int nBishops = pCnt[WhiteBishop+side] + pCnt[WhiteFerz+side]; @@ -7663,7 +7669,7 @@ Adjudicate (ChessProgramState *cps) // In any case it determnes if the game is a claimable draw (filling in EP_STATUS). // Actually ending the game is now based on the additional internal condition canAdjudicate. // Only when the game is ended, and the opponent is a computer, this opponent gets the move relayed. - int k, count = 0; static int bare = 1; + int k, drop, count = 0; static int bare = 1; ChessProgramState *engineOpponent = (gameMode == TwoMachinesPlay ? cps->other : (cps ? NULL : &first)); Boolean canAdjudicate = !appData.icsActive; @@ -7818,10 +7824,12 @@ Adjudicate (ChessProgramState *cps) /* Check for rep-draws */ count = 0; + drop = gameInfo.holdingsSize && (gameInfo.variant != VariantSuper && gameInfo.variant != VariantSChess + && gameInfo.variant != VariantGreat && gameInfo.variant != VariantGrand); for(k = forwardMostMove-2; - k>=backwardMostMove && k>=forwardMostMove-100 && + k>=backwardMostMove && k>=forwardMostMove-100 && (drop || (signed char)boards[k][EP_STATUS] < EP_UNKNOWN && - (signed char)boards[k+2][EP_STATUS] <= EP_NONE && (signed char)boards[k+1][EP_STATUS] <= EP_NONE; + (signed char)boards[k+2][EP_STATUS] <= EP_NONE && (signed char)boards[k+1][EP_STATUS] <= EP_NONE); k-=2) { int rights=0; if(CompareBoards(boards[k], boards[forwardMostMove])) { @@ -8109,9 +8117,13 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if(appData.debugMode) fprintf(debugFP, "pause %s engine after move\n", cps->which); safeStrCpy(stashedInputMove, message, MSG_SIZ); stalledEngine = cps; - if(appData.ponderNextMove) { // bring both engines out of ponder - SendToProgram("easy\n", &first); - if(gameMode == TwoMachinesPlay) SendToProgram("easy\n", &second); + if(appData.ponderNextMove) { // bring opponent out of ponder + if(gameMode == TwoMachinesPlay) { + if(cps->other->pause) + PauseEngine(cps->other); + else + SendToProgram("easy\n", cps->other); + } } StopClocks(); return; @@ -12338,9 +12350,7 @@ LoadGame (FILE *f, int gameNumber, char *title, int useList) if (oldGameMode == AnalyzeFile || oldGameMode == AnalyzeMode) { appData.loadGameIndex = -1; // [HGM] order auto-stepping through games - keepInfo = 1; AnalyzeFileEvent(); - keepInfo = 0; } if(creatingBook) return TRUE; @@ -13402,7 +13412,7 @@ PauseEvent () if(stalledEngine) { // [HGM] pause: resume game by releasing withheld move StartClocks(); if(gameMode == TwoMachinesPlay) { // we might have to make the opponent resume pondering - if(stalledEngine->other->pause) UnPauseEngine(stalledEngine->other); + if(stalledEngine->other->pause == 2) UnPauseEngine(stalledEngine->other); else if(appData.ponderNextMove) SendToProgram("hard\n", stalledEngine->other); } if(appData.ponderNextMove) SendToProgram("hard\n", stalledEngine); @@ -13428,7 +13438,7 @@ PauseEvent () Reset(FALSE, TRUE); SendToICS(ics_prefix); SendToICS("refresh\n"); - } else if (currentMove < forwardMostMove) { + } else if (currentMove < forwardMostMove && gameMode != AnalyzeMode) { ForwardInner(forwardMostMove); } pauseExamInvalid = FALSE; @@ -13468,16 +13478,16 @@ PauseEvent () else SendToProgram("easy\n", onMove->other); StopClocks(); - } + } else if(appData.ponderNextMove) SendToProgram("easy\n", onMove); // pre-emptively bring out of ponder } else if(gameMode == (WhiteOnMove(forwardMostMove) ? MachinePlaysWhite : MachinePlaysBlack)) { // engine on move if(first.pause) { PauseEngine(&first); StopClocks(); - } + } else if(appData.ponderNextMove) SendToProgram("easy\n", &first); // pre-emptively bring out of ponder } else { // human on move, pause pondering by either method if(first.pause) PauseEngine(&first); - else + else if(appData.ponderNextMove) SendToProgram("easy\n", &first); StopClocks(); } @@ -13617,7 +13627,9 @@ AnalyzeFileEvent () } if (gameMode != AnalyzeMode) { + keepInfo = 1; // mere annotating should not alter PGN tags EditGameEvent(); + keepInfo = 0; if (gameMode != EditGame) return; if (!appData.showThinking) ToggleShowThinking(); ResurrectChessProgram(); @@ -13630,7 +13642,6 @@ AnalyzeFileEvent () gameMode = AnalyzeFile; pausing = FALSE; ModeHighlight(); - SetGameInfo(); StartAnalysisClock(); GetTimeMark(&lastNodeCountTime);