Improve Eval Graph with -evalZoom and -evalThreshold
[xboard.git] / evalgraph.c
index 9aa1fe7..a24ba02 100644 (file)
@@ -50,6 +50,7 @@ ChessProgramStats_Move * currPvInfo;
 int currFirst = 0;
 int currLast = 0;
 int currCurrent = -1;
+int range = 1;
 
 int nWidthPB = 0;
 int nHeightPB = 0;
@@ -84,6 +85,19 @@ static int GetPvScore( int index )
     return score;
 }
 
+char* MakeEvalTitle( char * title)
+{
+    int score = currPvInfo[ currCurrent ].score;
+    int depth = currPvInfo[ currCurrent ].depth;
+    static char buf[MSG_SIZ];
+
+    if( depth <=0 ) return title;
+    if( currCurrent & 1 ) score = -score; /* Flip score for black */
+    snprintf(buf, MSG_SIZ, "%s {%s%.2f/%-2d %d}", title, score>0 ? "+" : " ", score/100., depth, (currPvInfo[currCurrent].time+50)/100);
+
+    return buf;
+}
+
 // back-end
 /*
     For a centipawn value, this function returns the height of the corresponding
@@ -93,23 +107,25 @@ static int GetPvScore( int index )
 */
 static int GetValueY( int value )
 {
-    if( value < -700 ) value = -700;
-    if( value > +700 ) value = +700;
-
-    return (nHeightPB / 2) - (int)(value * (nHeightPB - 2*MarginH) / 1400.0);
+    if( value < -range*700 ) value = -range*700;
+    if( value > +range*700 ) value = +range*700;
+    if(value > 100*range)  value += appData.zoom * 100 - 100*range; else
+    if(value < -100*range) value -= appData.zoom * 100 - 100*range; else
+       value *= appData.zoom;
+    return (nHeightPB / 2) - (int)(value * (nHeightPB - 2*MarginH) / ((1200. + 200.*appData.zoom)*range));
 }
 
 // the brush selection is made part of the DrawLine, by passing a style argument
 // the wrapper for doing the text output makes this back-end
 static void DrawAxisSegmentHoriz( int value, Boolean drawValue )
 {
-    int y = GetValueY( value*100 );
+    int y = GetValueY( range*value*100 );
 
     if( drawValue ) {
         char buf[MSG_SIZ], *b = buf;
 
         if( value > 0 ) *b++ = '+';
-       sprintf(b, "%d", value);
+       sprintf(b, "%d", range*value);
 
        DrawEvalText(buf, strlen(buf), y);
     }
@@ -145,7 +161,7 @@ static void DrawHistogram( int x, int y, int width, int value, int side )
 {
     int left, top, right, bottom;
 
-    if( value > -25 && value < +25 ) return;
+    if( value > -appData.evalThreshold*range && value < +appData.evalThreshold*range ) return;
 
     left = x;
     right = left + width + 1;
@@ -328,6 +344,8 @@ int GetMoveIndexFromPoint( int x, int y )
 // init and display part split of so they can be moved to front end
 void PaintEvalGraph( void )
 {
+    VariantClass v = gameInfo.variant;
+    range = (gameInfo.holdingsWidth && v != VariantSuper && v != VariantGreat && v != VariantSChess) ? 2 : 1; // [HGM] double range in drop games
     /* Draw */
     DrawRectangle(0, 0, nWidthPB, nHeightPB, 2, FILLED);
     DrawAxis();