Implement multi-PV
authorH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 11 Apr 2018 18:15:26 +0000 (20:15 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Thu, 12 Apr 2018 07:14:25 +0000 (09:14 +0200)
An option 'Multi-PV margin' is added to set a margin in centi-Pawn.
This margin is than subtracted from the bestScore in the root to get alpha.
For this, bestScore an alpha must be increased inependently, as scores
can exceed alpha without exceding bestScore. The Multi-PV option has to be
recognized with the options that require a search abort, to make a new
analysis search start.

dropper.c

index 07fe17d..de421e3 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -70,7 +70,7 @@ typedef long long int Key;
 
 int ply, nodeCount, forceMove, choice, rootMove, lastGameMove, rootScore, abortFlag, postThinking=1; // some frequently used data
 int maxDepth=MAXPLY-2, timeControl=3000, mps=40, inc, timePerMove, timeLeft=1000; // TC parameters
-int rootFirst, rootCurrent, rootLast, rootPly;
+int rootFirst, rootCurrent, rootLast, rootPly, margin;
 
 #define H_LOWER 1
 #define H_UPPER 2
@@ -1498,11 +1498,10 @@ printf("%d:%d:%d %2d. %08x %c%d%c%d %6d %6d %6d\n",ply,depth,iterDepth,curMove,m
            if(f.depth < resultDepth) resultDepth = f.depth;
            if(f.lim > upperScore) upperScore = f.lim;
 
-           if(score > bestScore) {
-               bestScore = score;
-               if(score > alpha) {
+           if(score > bestScore) bestScore = score, bestNr = curMove;
+           if(score > alpha) {
                    int *tail;
-                   alpha = score; bestNr = curMove;
+                   alpha = score;
                    history[moveStack[curMove] & 0xFFFF] += iterDepth*iterDepth;
                    if(score > INF-100 && curMove >= m.nonCapts)
                        mateKillers[(ff->wholeMove & 0xFFFF) + (stm - WHITE << 11)] = moveStack[curMove] & 0xFFFF | f.xking << 16 | board[f.toSqr] << 24; // store mate killers
@@ -1520,8 +1519,8 @@ printf("%d:%d:%d %2d. %08x %c%d%c%d %6d %6d %6d\n",ply,depth,iterDepth,curMove,m
                        for(tail=pvStart; *tail; tail++) printf(" %s", MoveToText(*tail));
                        printf("\n"); fflush(stdout);
                        ff->move = moveStack[bestNr];
+                       alpha = bestScore - margin;
                    }
-               }
            }
            if(ply == 0) rootFirst = m.firstMove, rootLast = moveSP, rootCurrent = curMove, rootPly = iterDepth;
        }   // move loop
@@ -1867,7 +1866,6 @@ printf("# command: %s\n", inBuf);
     if(!strcmp(command, "option")) { // setting of engine-define option; find out which
       if(sscanf(inBuf+7, "Resign=%d",   &resign)         == 1) return 0;
       if(sscanf(inBuf+7, "Contempt=%d", &contemptFactor) == 1) return 0;
-      return 1;
     }
 
     if(searching) {
@@ -1893,9 +1891,14 @@ printf("# command: %s\n", inBuf);
                                "5x5+4_shogi,5x5+5_shogi,6x6+6_shogi,7x7+6_shogi,11x17+16_chu\"\n");
       printf("feature option=\"Resign -check 0\"\n");           // example of an engine-defined option
       printf("feature option=\"Contempt -spin 0 -200 200\"\n"); // and another one
+      printf("feature option=\"Multi-PV margin -spin 0 0 10000\"\n");
       printf("feature done=1\n");
       return 1;
     }
+    if(!strcmp(command, "option")) { // engine-defined options that must abort search
+      if(sscanf(inBuf+7, "Multi-PV margin=%d", &margin)  == 1) return 1;
+      return 1;
+    }
     if(!strcmp(command, "sd"))      { sscanf(inBuf+2, "%d", &maxDepth);    return 1; }
     if(!strcmp(command, "st"))      { sscanf(inBuf+2, "%d", &timePerMove); return 1; }
     if(!strcmp(command, "memory"))  { if(SetMemorySize(atoi(inBuf+7))) printf("tellusererror Not enough memory\n"), exit(-1); return 1; }