X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=d9674850a9838df008f658dd44ae30deb93c21c8;hb=decfbd9ac05e334925c9c8ecc6b739ffc9b2b8f6;hp=3eea34d3a6e3d4ec8f18f81a49bea9c6059d0b7e;hpb=eca6bb833394a9a378dd209cefb2c1a5e721f2a9;p=xboard.git diff --git a/backend.c b/backend.c index 3eea34d..d967485 100644 --- a/backend.c +++ b/backend.c @@ -996,6 +996,7 @@ Load (ChessProgramState *cps, int i) SwapEngines(i); ReplaceEngine(cps, i); FloatToFront(&appData.recentEngineList, engineLine); + if(gameMode == BeginningOfGame) Reset(TRUE, TRUE); return; } p = engineName; @@ -1585,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(); } @@ -1743,6 +1744,11 @@ InitBackEnd3 P((void)) CopyBoard(filePosition, boards[0]); CopyBoard(initialPosition, boards[0]); } + } else if(*appData.fen != NULLCHAR) { + if(ParseFEN(filePosition, &blackPlaysFirst, appData.fen, TRUE) && !blackPlaysFirst) { + startedFromPositionFile = TRUE; + Reset(TRUE, TRUE); + } } if (initialMode == AnalyzeMode) { if (appData.noChessProgram) { @@ -6454,6 +6460,7 @@ InitPosition (int redraw) initialRights[i] = filePosition[CASTLING][i]; startedFromSetupPosition = TRUE; } + if(*appData.men) LoadPieceDesc(appData.men); CopyBoard(boards[0], initialPosition); @@ -8050,6 +8057,9 @@ SendProgramStatsToFrontend (ChessProgramState * cps, ChessProgramStats * cpstats if(stats.pv && stats.pv[0]) safeStrCpy(lastPV[stats.which], stats.pv, sizeof(lastPV[stats.which])/sizeof(lastPV[stats.which][0])); // [HGM] pv: remember last PV of each + if( gameMode == AnalyzeMode && stats.pv && stats.pv[0] + && appData.analysisBell && stats.time >= 100*appData.analysisBell ) RingBell(); + SetProgramStats( &stats ); } @@ -8942,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. %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); @@ -9713,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)) { @@ -10783,6 +10801,7 @@ InitChessProgram (ChessProgramState *cps, int setup) b = SupportedVariant(cps->variants, gameInfo.variant, gameInfo.boardWidth, gameInfo.boardHeight, gameInfo.holdingsSize, cps->protocolVersion, cps->tidy); + if (b == NULL) { VariantClass v; char c, *q = cps->variants, *p = strchr(q, ','); @@ -11418,6 +11437,11 @@ NextMatchGame () res = LoadGameOrPosition(matchGame); // setup game appData.noChessProgram = FALSE; // LoadGameOrPosition might call Reset too! if(!res) return; // abort when bad game/pos file + if(appData.epd) {// in EPD mode we make sure first engine is to move + firstWhite = !(forwardMostMove & 1); + first.twoMachinesColor = firstWhite ? "white\n" : "black\n"; // perform actual color assignement + second.twoMachinesColor = firstWhite ? "black\n" : "white\n"; + } TwoMachinesEvent(); } @@ -11825,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, @@ -11965,7 +11997,10 @@ Reset (int redraw, int init) lastHint[0] = NULLCHAR; ClearGameInfo(&gameInfo); gameInfo.variant = StringToVariant(appData.variant); - if(gameInfo.variant == VariantNormal && strcmp(appData.variant, "normal")) gameInfo.variant = VariantUnknown; + if(gameInfo.variant == VariantNormal && strcmp(appData.variant, "normal")) { + gameInfo.variant = VariantUnknown; + strncpy(engineVariant, appData.variant, MSG_SIZ); + } ics_user_moved = ics_clock_paused = FALSE; ics_getting_history = H_FALSE; ics_gamenum = -1; @@ -12928,7 +12963,7 @@ LoadGame (FILE *f, int gameNumber, char *title, int useList) char buf[MSG_SIZ]; int gn = gameNumber; ListGame *lg = NULL; - int numPGNTags = 0; + int numPGNTags = 0, i; int err, pos = -1; GameMode oldGameMode; VariantClass v, oldVariant = gameInfo.variant; /* [HGM] PGNvariant */ @@ -13117,6 +13152,8 @@ LoadGame (FILE *f, int gameNumber, char *title, int useList) if (appData.debugMode) fprintf(debugFP, "Parsed game start '%s' (%d)\n", yy_text, (int) cm); + for(i=0; i