changes from H.G. Muller; version 4.3.16
[xboard.git] / zippy.c
diff --git a/zippy.c b/zippy.c
index f75ecb2..c77276f 100644 (file)
--- a/zippy.c
+++ b/zippy.c
@@ -88,6 +88,8 @@ extern char *getenv();
 #include "backend.h"\r
 #include "backendz.h"\r
 \r
+char *SendMoveToBookUser P((int nr, ChessProgramState *cps, int initial)); // [HGM] book
+
 static char zippyPartner[MSG_SIZ];\r
 static char zippyLastOpp[MSG_SIZ];\r
 static int zippyConsecGames;\r
@@ -964,7 +966,8 @@ void ZippyFirstBoard(moveNum, basetime, increment)
     char buf[MSG_SIZ];\r
     int w, b;\r
     char *opp = (gameMode==IcsPlayingWhite ? gameInfo.black : gameInfo.white);\r
-    Boolean sentPos = FALSE;\r
+    Boolean sentPos = FALSE;
+    char *bookHit = NULL; // [HGM] book\r
 \r
     if (!first.initDone) {\r
       /* Game is starting prematurely.  We can't deal with this */\r
@@ -1035,7 +1038,7 @@ void ZippyFirstBoard(moveNum, basetime, increment)
                  SendTimeRemaining(&first, TRUE);\r
                }\r
              }\r
-             SendToProgram("go\n", &first);\r
+             bookHit = SendMoveToBookUser(forwardMostMove-1, &first, TRUE); // [HGM] book: send go or retrieve book move\r
            } else {\r
                /* Engine's opponent is on move now */\r
                if (first.usePlayother) {\r
@@ -1061,7 +1064,8 @@ void ZippyFirstBoard(moveNum, basetime, increment)
                  SendTimeRemaining(&first, TRUE);\r
                }\r
              }\r
-             SendToProgram("go\n", &first);\r
+//           SendToProgram("go\n", &first);\r
+             bookHit = SendMoveToBookUser(forwardMostMove-1, &first, TRUE); // [HGM] book: send go or retrieve book move\r
            }\r
        }\r
     } else if (gameMode == IcsPlayingBlack) {\r
@@ -1085,7 +1089,8 @@ void ZippyFirstBoard(moveNum, basetime, increment)
                  SendTimeRemaining(&first, FALSE);\r
                }\r
              }\r
-             SendToProgram("go\n", &first);\r
+//           SendToProgram("go\n", &first);\r
+             bookHit = SendMoveToBookUser(forwardMostMove-1, &first, TRUE); // [HGM] book: send go or retrieve book move\r
            } else {\r
                /* Engine's opponent is on move now */\r
                if (first.usePlayother) {\r
@@ -1103,6 +1108,18 @@ void ZippyFirstBoard(moveNum, basetime, increment)
            /* Nothing needs to be done here */\r
        }       \r
     }\r
+
+    if(bookHit) { // [HGM] book: simulate book reply
+       static char bookMove[MSG_SIZ]; // a bit generous?
+
+       programStats.depth = programStats.nodes = programStats.time = 
+       programStats.score = programStats.got_only_move = 0;
+       sprintf(programStats.movelist, "%s (xbook)", bookHit);
+
+       strcpy(bookMove, "move ");
+       strcat(bookMove, bookHit);
+       HandleMachineMove(bookMove, &first);
+    }
 }\r
 \r
 \r