Print mate scores as #N in message field
authorH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 20 Oct 2015 15:22:53 +0000 (17:22 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 20 Oct 2015 15:22:53 +0000 (17:22 +0200)
backend.c
common.h
engineoutput.c

index f1dcf5d..bd37f6d 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -9533,6 +9533,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h
            buf1[0] = NULLCHAR;
            if (sscanf(message, "%d%c %d %d " u64Display " %[^\n]\n",
                       &plylev, &plyext, &curscore, &time, &nodes, buf1) >= 5) {
+               char score_buf[MSG_SIZ];
 
                if(nodes>>32 == u64Const(0xFFFFFFFF))   // [HGM] negative node count read
                    nodes += u64Const(0x100000000);
@@ -9633,11 +9634,17 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h
                     [AS] Protect the thinkOutput buffer from overflow... this
                     is only useful if buf1 hasn't overflowed first!
                 */
-               snprintf(thinkOutput, sizeof(thinkOutput)/sizeof(thinkOutput[0]), "[%d]%c%+.2f %s%s",
+               if(curscore >= MATE_SCORE) 
+                   snprintf(score_buf, MSG_SIZ, "#%d", curscore - MATE_SCORE);
+               else if(curscore <= -MATE_SCORE) 
+                   snprintf(score_buf, MSG_SIZ, "#%d", curscore + MATE_SCORE);
+               else
+                   snprintf(score_buf, MSG_SIZ, "%+.2f", ((double) curscore) / 100.0);
+               snprintf(thinkOutput, sizeof(thinkOutput)/sizeof(thinkOutput[0]), "[%d]%c%s %s%s",
                         plylev,
                         (gameMode == TwoMachinesPlay ?
                          ToUpper(cps->twoMachinesColor[0]) : ' '),
-                        ((double) curscore) / 100.0,
+                        score_buf,
                         prefixHint ? lastHint : "",
                         prefixHint ? " " : "" );
 
index 5c7b6d2..4f5b85b 100644 (file)
--- a/common.h
+++ b/common.h
@@ -226,6 +226,7 @@ typedef char *String;
 #define BELLCHAR                '\007'
 #define NULLCHAR                '\000'
 #define FEATURE_TIMEOUT         10000 /*ms*/
+#define MATE_SCORE              100000
 
 #define CLOCK_FONT 0
 #define MESSAGE_FONT 1
index 522a186..d6fde3c 100644 (file)
@@ -443,7 +443,6 @@ InsertionPoint (int len, EngineOutputData *ed)
       return offs + strlen(header[ed->which]);
 }
 
-#define MATE_SCORE 100000
 static char spaces[] = "            "; // [HGM] align: spaces for padding
 
 static void