Clear total solving time at start of match
[xboard.git] / backend.c
index 7f8bc87..d967485 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1586,7 +1586,7 @@ MatchEvent (int mode)
        }
        matchMode = mode;
        matchGame = roundNr = 1;
-       first.matchWins = second.matchWins = 0; // [HGM] match: needed in later matches
+       first.matchWins = second.matchWins = totalTime = 0; // [HGM] match: needed in later matches
        NextMatchGame();
 }
 
@@ -8952,10 +8952,10 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h
         }
         if(appData.epd) {
            if(solvingTime >= 0) {
-              snprintf(buf1, MSG_SIZ, "%d. solved %4.2fs\n", matchGame, solvingTime/100.);
-              totalTime += solvingTime; first.matchWins++;
+              snprintf(buf1, MSG_SIZ, _("%d. solved %4.2fs\n"), matchGame, solvingTime/100.);
+              totalTime += solvingTime; first.matchWins++; solvingTime = -1;
            } else {
-              snprintf(buf1, MSG_SIZ, "%d. wrong (%s)\n", matchGame, parseList[backwardMostMove]);
+              snprintf(buf1, MSG_SIZ, _("%d. wrong (%s)\n"), matchGame, parseList[backwardMostMove]);
               second.matchWins++;
            }
            OutputKibitz(2, buf1);
@@ -9723,10 +9723,18 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h
 
                if(*bestMove) { // rememer time best EPD move was first found
                    int ff1, tf1, fr1, tr1, ff2, tf2, fr2, tr2; char pp1, pp2;
-                   ChessMove mt;
-                   int ok = ParseOneMove(bestMove, forwardMostMove, &mt, &ff1, &fr1, &tf1, &tr1, &pp1);
-                   ok    &= ParseOneMove(pv, forwardMostMove, &mt, &ff2, &fr2, &tf2, &tr2, &pp2);
-                   solvingTime = (ok && ff1==ff2 && fr1==fr2 && tf1==tf2 && tr1==tr2 && pp1==pp2 ? time : -1);
+                   ChessMove mt; char *p = bestMove, solved = 0;
+                   int ok = ParseOneMove(pv, forwardMostMove, &mt, &ff2, &fr2, &tf2, &tr2, &pp2);
+                   while(ok && *p && ParseOneMove(p, forwardMostMove, &mt, &ff1, &fr1, &tf1, &tr1, &pp1)) {
+                       if(ff1==ff2 && fr1==fr2 && tf1==tf2 && tr1==tr2 && pp1==pp2) {
+                           solvingTime = (solvingTime < 0 ? time : solvingTime);
+                           solved = 1;
+                           break;
+                       }
+                       while(*p && *p != ' ') p++;
+                       while(*p == ' ') p++;
+                   }
+                   if(!solved) solvingTime = -1;
                }
 
                if(serverMoves && (time > 100 || time == 0 && plylev > 7)) {
@@ -11841,6 +11849,14 @@ GameEnds (ChessMove result, char *resultDetails, int whosays)
            return;
        } else {
            gameMode = nextGameMode;
+           if(appData.epd) {
+               snprintf(buf, MSG_SIZ, "-------------------------------------- ");
+               OutputKibitz(2, buf);
+               snprintf(buf, MSG_SIZ, _("Average solving time %4.2f sec "), totalTime/(100.*first.matchWins));
+               OutputKibitz(2, buf);
+               snprintf(buf, MSG_SIZ, _("Solved %d of %d (%3.1f%%) "), first.matchWins, nextGame, first.matchWins*100./nextGame);
+               OutputKibitz(2, buf);
+           }
            snprintf(buf, MSG_SIZ, _("Match %s vs. %s: final score %d-%d-%d"),
                     first.tidy, second.tidy,
                     first.matchWins, second.matchWins,
@@ -13532,7 +13548,7 @@ LoadPosition (FILE *f, int positionNumber, char *title)
            return FALSE;
        }
        if((strchr(line, ';')) && (p = strstr(line, " bm "))) { // EPD with best move
-           sscanf(p+4, "%s", bestMove);
+           sscanf(p+4, "%[^;]", bestMove);
        } else *bestMove = NULLCHAR;
     } else {
        (void) fgets(line, MSG_SIZ, f);