From 90f6f34297e5405cef465d82f14bbda2674f032f Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 7 May 2009 21:45:25 -0700 Subject: [PATCH] added firstOptions, secondOptions, noGUI, firstXBook, secondXBook --- backend.c | 55 ++++++++++++++++++++++++++++++++------------------ backend.h | 1 + common.h | 2 + winboard/winboard.c | 6 +++++ xboard.c | 23 ++++++++++++++------ 5 files changed, 60 insertions(+), 27 deletions(-) diff --git a/backend.c b/backend.c index b8cfa92..7dfb130 100644 --- a/backend.c +++ b/backend.c @@ -759,6 +759,10 @@ InitBackEnd1() first.debug = second.debug = FALSE; first.supportsNPS = second.supportsNPS = UNKNOWN; + /* [HGM] options */ + first.optionSettings = appData.firstOptions; + second.optionSettings = appData.secondOptions; + first.scoreIsAbsolute = appData.firstScoreIsAbsolute; /* [AS] */ second.scoreIsAbsolute = appData.secondScoreIsAbsolute; /* [AS] */ first.isUCI = appData.firstIsUCI; /* [AS] */ @@ -7331,15 +7335,15 @@ MakeMove(fromX, fromY, toX, toY, promoChar) int fromX, fromY, toX, toY; int promoChar; { - forwardMostMove++; +// forwardMostMove++; // [HGM] bare: moved downstream - if(serverMoves != NULL) { /* [HGM] write moves on file for broadcasting */ + if(serverMoves != NULL) { /* [HGM] write moves on file for broadcasting (should be separate routine, really) */ int timeLeft; static int lastLoadFlag=0; int king, piece; - piece = boards[forwardMostMove-1][fromY][fromX]; + piece = boards[forwardMostMove][fromY][fromX]; king = piece < (int) BlackPawn ? WhiteKing : BlackKing; if(gameInfo.variant == VariantKnightmate) king += (int) WhiteUnicorn - (int) WhiteKing; - if(forwardMostMove == 1) { + if(forwardMostMove == 0) { if(blackPlaysFirst) fprintf(serverMoves, "%s;", second.tidy); fprintf(serverMoves, "%s;", first.tidy); @@ -7357,9 +7361,9 @@ MakeMove(fromX, fromY, toX, toY, promoChar) fprintf(serverMoves, ":%c%c:%c%c", AAA+BOARD_LEFT, ONE+fromY, AAA+toX+1,ONE+toY); } // e.p. suffix - if( (boards[forwardMostMove-1][fromY][fromX] == WhitePawn || - boards[forwardMostMove-1][fromY][fromX] == BlackPawn ) && - boards[forwardMostMove-1][toY][toX] == EmptySquare + if( (boards[forwardMostMove][fromY][fromX] == WhitePawn || + boards[forwardMostMove][fromY][fromX] == BlackPawn ) && + boards[forwardMostMove][toY][toX] == EmptySquare && fromX != toX ) fprintf(serverMoves, ":%c%c:%c%c", AAA+fromX, ONE+fromY, AAA+toX, ONE+fromY); // promotion suffix @@ -7367,28 +7371,29 @@ MakeMove(fromX, fromY, toX, toY, promoChar) fprintf(serverMoves, ":%c:%c%c", promoChar, AAA+toX, ONE+toY); if(!loadFlag) { fprintf(serverMoves, "/%d/%d", - pvInfoList[forwardMostMove-1].depth, pvInfoList[forwardMostMove-1].score); - if(forwardMostMove & 1) timeLeft = whiteTimeRemaining/1000; - else timeLeft = blackTimeRemaining/1000; + pvInfoList[forwardMostMove].depth, pvInfoList[forwardMostMove].score); + if(forwardMostMove+1 & 1) timeLeft = whiteTimeRemaining/1000; + else timeLeft = blackTimeRemaining/1000; fprintf(serverMoves, "/%d", timeLeft); } fflush(serverMoves); } - if (forwardMostMove >= MAX_MOVES) { + if (forwardMostMove+1 >= MAX_MOVES) { DisplayFatalError(_("Game too long; increase MAX_MOVES and recompile"), 0, 1); return; } SwitchClocks(); - timeRemaining[0][forwardMostMove] = whiteTimeRemaining; - timeRemaining[1][forwardMostMove] = blackTimeRemaining; - if (commentList[forwardMostMove] != NULL) { - free(commentList[forwardMostMove]); - commentList[forwardMostMove] = NULL; - } - CopyBoard(boards[forwardMostMove], boards[forwardMostMove - 1]); - ApplyMove(fromX, fromY, toX, toY, promoChar, boards[forwardMostMove]); + timeRemaining[0][forwardMostMove+1] = whiteTimeRemaining; + timeRemaining[1][forwardMostMove+1] = blackTimeRemaining; + if (commentList[forwardMostMove+1] != NULL) { + free(commentList[forwardMostMove+1]); + commentList[forwardMostMove+1] = NULL; + } + CopyBoard(boards[forwardMostMove+1], boards[forwardMostMove]); + ApplyMove(fromX, fromY, toX, toY, promoChar, boards[forwardMostMove+1]); + forwardMostMove++; // [HGM] bare: moved to after ApplyMove, to make sure clock interrupt finds complete board gameInfo.result = GameUnfinished; if (gameInfo.resultDetails != NULL) { free(gameInfo.resultDetails); @@ -12377,6 +12382,14 @@ ParseOption(Option *opt, ChessProgramState *cps) opt->type = SaveButton; } else return FALSE; *p = 0; // terminate option name + // now look if the command-line options define a setting for this engine option. + p = strstr(cps->optionSettings, opt->name); + if(p == cps->optionSettings || p[-1] == ',') { + sprintf(buf, "option %s", p); + if(p = strstr(buf, ",")) *p = 0; + strcat(buf, "\n"); + SendToProgram(buf, cps); + } return TRUE; } @@ -12584,6 +12597,8 @@ DisplayMove(moveNumber) char res[MSG_SIZ]; char cpThinkOutput[MSG_SIZ]; + if(appData.noGUI) return; // [HGM] fast: suppress display of moves + if (moveNumber == forwardMostMove - 1 || gameMode == AnalyzeMode || gameMode == AnalyzeFile) { @@ -12621,7 +12636,7 @@ DisplayMove(moveNumber) } else { res[0] = NULLCHAR; } - + if (moveNumber < 0 || parseList[moveNumber][0] == NULLCHAR) { DisplayMessage(res, cpThinkOutput); } else { diff --git a/backend.h b/backend.h index 840dda3..43a479d 100644 --- a/backend.h +++ b/backend.h @@ -326,6 +326,7 @@ typedef struct _CPS { Option option[MAX_OPTIONS]; int comboCnt; char *comboList[10*MAX_OPTIONS]; + char *optionSettings; void *programLogo; /* [HGM] logo: bitmap of the logo */ } ChessProgramState; diff --git a/common.h b/common.h index 7883184..5e51bfd 100644 --- a/common.h +++ b/common.h @@ -585,6 +585,8 @@ typedef struct { char *secondLogo; Boolean autoLogo; Boolean noGUI; /* [HGM] fast: suppress all display updates */ + char *firstOptions; /* [HGM] options */ + char *secondOptions; } AppData, *AppDataPtr; /* [AS] PGN tags (for showing in the game list) */ diff --git a/winboard/winboard.c b/winboard/winboard.c index fb64ff7..115b2c3 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -1162,8 +1162,10 @@ ArgDescriptor argDescriptors[] = { { "sUCI", ArgTrue, (LPVOID) &appData.secondIsUCI, FALSE }, { "firstHasOwnBookUCI", ArgBoolean, (LPVOID) &appData.firstHasOwnBookUCI, FALSE }, { "fNoOwnBookUCI", ArgFalse, (LPVOID) &appData.firstHasOwnBookUCI, FALSE }, + { "firstXBook", ArgFalse, (LPVOID) &appData.firstHasOwnBookUCI, FALSE }, { "secondHasOwnBookUCI", ArgBoolean, (LPVOID) &appData.secondHasOwnBookUCI, FALSE }, { "sNoOwnBookUCI", ArgFalse, (LPVOID) &appData.secondHasOwnBookUCI, FALSE }, + { "secondXBook", ArgFalse, (LPVOID) &appData.secondHasOwnBookUCI, FALSE }, { "polyglotDir", ArgFilename, (LPVOID) &appData.polyglotDir, TRUE }, { "usePolyglotBook", ArgBoolean, (LPVOID) &appData.usePolyglotBook, TRUE }, { "polyglotBook", ArgFilename, (LPVOID) &appData.polyglotBook, TRUE }, @@ -1218,6 +1220,8 @@ ArgDescriptor argDescriptors[] = { { "firstLogo", ArgFilename, (LPVOID) &appData.firstLogo, FALSE }, { "secondLogo", ArgFilename, (LPVOID) &appData.secondLogo, FALSE }, { "autoLogo", ArgBoolean, (LPVOID) &appData.autoLogo, TRUE }, + { "firstOptions", ArgString, (LPVOID) &appData.firstOptions, FALSE }, + { "secondOptions", ArgString, (LPVOID) &appData.secondOptions, FALSE }, #ifdef ZIPPY { "zippyTalk", ArgBoolean, (LPVOID) &appData.zippyTalk, FALSE }, @@ -1936,6 +1940,8 @@ InitAppData(LPSTR lpCmdLine) appData.defaultHashSize = 64; appData.defaultCacheSizeEGTB = 4; appData.defaultPathEGTB = "c:\\egtb"; + appData.firstOptions = ""; + appData.secondOptions = ""; InitWindowPlacement( &wpMoveHistory ); InitWindowPlacement( &wpEvalGraph ); diff --git a/xboard.c b/xboard.c index 1f17046..e41119e 100644 --- a/xboard.c +++ b/xboard.c @@ -1309,6 +1309,18 @@ XtResource clientResources[] = { { "niceEngines", "niceEngines", XtRInt, sizeof(int), XtOffset(AppDataPtr, niceEngines), XtRImmediate, (XtPointer) 0}, + { "nameOfDebugFile", "nameOfDebugFile", XtRString, + sizeof(String), XtOffset(AppDataPtr, nameOfDebugFile), + XtRImmediate, (XtPointer) "xboard.debug"}, + { "noGUI", "noGUI", XtRBoolean, + sizeof(Boolean), XtOffset(AppDataPtr, noGUI), + XtRImmediate, (XtPointer) 0}, + { "firstOptions", "firstOptions", XtRString, + sizeof(String), XtOffset(AppDataPtr, firstOptions), + XtRImmediate, (XtPointer) "" }, + { "secondOptions", "secondOptions", XtRString, + sizeof(String), XtOffset(AppDataPtr, secondOptions), + XtRImmediate, (XtPointer) "" }, // [HGM] Winboard_x UCI options { "firstIsUCI", "firstIsUCI", XtRBoolean, @@ -1347,12 +1359,6 @@ XtResource clientResources[] = { { "delayAfterQuit", "delayAfterQuit", XtRInt, sizeof(int), XtOffset(AppDataPtr, delayAfterQuit), XtRImmediate, (XtPointer) 0}, - { "nameOfDebugFile", "nameOfDebugFile", XtRString, - sizeof(String), XtOffset(AppDataPtr, nameOfDebugFile), - XtRImmediate, (XtPointer) "xboard.debug"}, - { "noGUI", "noGUI", XtRBoolean, - sizeof(Boolean), XtOffset(AppDataPtr, noGUI), - XtRImmediate, (XtPointer) 0}, }; XrmOptionDescRec shellOptions[] = { @@ -1658,6 +1664,8 @@ XrmOptionDescRec shellOptions[] = { { "-secondHasOwnBookUCI", "secondHasOwnBookUCI", XrmoptionSepArg, NULL }, { "-fNoOwnBookUCI", "firstHasOwnBookUCI", XrmoptionNoArg, "False" }, { "-sNoOwnBookUCI", "secondHasOwnBookUCI", XrmoptionNoArg, "False" }, + { "-firstXBook", "firstHasOwnBookUCI", XrmoptionNoArg, "False" }, + { "-secondXBook", "secondHasOwnBookUCI", XrmoptionNoArg, "False" }, { "-polyglotDir", "polyglotDir", XrmoptionSepArg, NULL }, { "-usePolyglotBook", "usePolyglotBook", XrmoptionSepArg, NULL }, { "-polyglotBook", "polyglotBook", XrmoptionSepArg, NULL }, @@ -1707,6 +1715,8 @@ XrmOptionDescRec shellOptions[] = { { "-delayAfterQuit", "delayAfterQuit", XrmoptionSepArg, NULL }, { "-nameOfDebugFile", "nameOfDebugFile", XrmoptionSepArg, NULL }, { "-noGUI", "noGUI", XrmoptionNoArg, "True" }, + { "-firstOptions", "firstOptions", XrmoptionSepArg, NULL }, + { "-secondOptions", "secondOptions", XrmoptionSepArg, NULL }, }; @@ -2268,7 +2278,6 @@ main(argc, argv) #ifdef ENABLE_NLS XtSetLanguageProc(NULL, NULL, NULL); bindtextdomain(PRODUCT, LOCALEDIR); - bind_textdomain_codeset(PRODUCT, "UTF-8"); textdomain(PRODUCT); #endif -- 1.7.0.4