added firstOptions, secondOptions, noGUI, firstXBook, secondXBook
authorH.G. Muller <h.g.muller@hccnet.nl>
Fri, 8 May 2009 04:45:25 +0000 (21:45 -0700)
committerArun Persaud <arun@nubati.net>
Fri, 8 May 2009 04:45:25 +0000 (21:45 -0700)
backend.c
backend.h
common.h
winboard/winboard.c
xboard.c

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