X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fcommondsp.c;h=4c6dfa42a90782d39588d7d7e77b84b9081e24bc;hb=21a60b5aae737b538480c4d8beee575b3d9a8e35;hp=a03d69d355b9f29ccf4bb119816018a2bb467012;hpb=a0c1400035104ea33d6eda049dbdb5fe2150de9a;p=gnushogi.git diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c index a03d69d..4c6dfa4 100644 --- a/gnushogi/commondsp.c +++ b/gnushogi/commondsp.c @@ -285,6 +285,7 @@ VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) MoveList(opponent, 2, -1, true); generate_move_flags = false; pnt = TrPnt[2]; + if(s[4] == '=') s[4] = '\0'; /* deferral is implied */ while (pnt < TrPnt[3]) { @@ -1617,8 +1618,8 @@ InputCommand(char *command, int root) #endif short ok, done, is_move = false; unsigned short mv; - char s[200], sx[200]; - static char backlog[200]; + char s[200], sx[200], s2[200]; + static char backlog[200], ponderString[20]; ok = flag.quit = done = false; player = opponent; @@ -1628,7 +1629,7 @@ InputCommand(char *command, int root) ZeroTTable(); #endif - if ((hint > 0) && !flag.easy && !flag.force && !command && !backlog[0] && root) + while ((hint > 0) && !flag.easy && !flag.force && !command && !backlog[0] && root) { /* * A hint move for the player is available. Compute a move for the @@ -1639,13 +1640,13 @@ InputCommand(char *command, int root) ft = time0; /* Save reference time for the player. */ fflush(stdout); algbr((short) hint >> 8, (short) hint & 0xff, false); - strcpy(s, mvstr[0]); + strcpy(ponderString, mvstr[0]); if (flag.post) dsp->GiveHint(); /* do the hint move */ - if (VerifyMove(s, VERIFY_AND_TRY_MODE, &mv)) + if (VerifyMove(ponderString, VERIFY_AND_TRY_MODE, &mv)) { Sdepth = 0; @@ -1680,12 +1681,27 @@ InputCommand(char *command, int root) } #endif - /* undo the hint and carry on */ - VerifyMove(s, UNMAKE_MODE, &mv); + if (strcmp(ponderString, "hit")) + { /* undo the hint and carry on */ + VerifyMove(ponderString, UNMAKE_MODE, &mv); + } + else + { /* otherwise SelectMove will have played the computer's reply */ + /* update ponder-move stats, which was skipped in TRY_MODE */ + GameList[GameCnt-1].depth = GameList[GameCnt].score = 0; + GameList[GameCnt-1].nodes = 0; + ElapsedTime(COMPUTE_AND_INIT_MODE); + GameList[GameCnt-1].time = (short) (et + 50)/100; /* FIXME: this is wrong */ + + if(TCflag && TimeControl.moves[computer] == 0) + SetTimeControl(); /* add time for next session */ + } Sdepth = 0; } time0 = ft; /* Restore reference time for the player. */ + ponderString[0] = '\0'; + /* on a ponder miss or other command, loop terminates because of backlog */ } while(!(ok || flag.quit || done)) @@ -1718,14 +1734,31 @@ InputCommand(char *command, int root) } else { strcpy(sx, command); backlog[0]= '\0'; /* make sure no backlog is left */ - done = true; + command = NULL; } /* extract first word */ - if (sscanf(sx, "%s", s) < 1) + if (sscanf(sx, "%s %s", s, s2) < 1) continue; - if (!root && strcmp(s, ".")) + if (!root && (strcmp(s, "usermove") == 0) + && (strcmp(s2, ponderString) == 0)) + { /* ponder hit; switch to normal search */ + background = false; + hint = 0; + if (TCflag) + { /* account opponent time and moves */ + TimeControl.clock[opponent] -= et; + timeopp[oppptr] = et; + --TimeControl.moves[opponent]; + if(TimeControl.moves[computer] == 0) SetTimeControl(); + } + SetResponseTime(computer); + strcpy(ponderString, "hit"); + return false; /* no search abort */ + } + + if (!root && strcmp(s, ".") && strcmp(s, "time") && strcmp(s, "otim")) { /* during search most commands can only be done after abort */ strcpy(backlog, sx); /* backlog the command */ return true; /* and order search abort */ @@ -1797,7 +1830,7 @@ InputCommand(char *command, int root) "shogi" #endif ); - printf("debug=1 setboard=0 sigint=0 memory=1 setboard=1 done=1\n"); + printf("debug=1 setboard=1 sigint=0 memory=1 usermove=1 done=1\n"); } else if (strcmp(s, ".") == 0) { // periodic update request of analysis info: send stat01 info @@ -2147,6 +2180,9 @@ InputCommand(char *command, int root) } else { + if (strcmp(s, "usermove") == 0) + sscanf(sx + 9, "%s", s); + if (flag.mate) { ok = true;