]> git.sesse.net Git - stockfish/commitdiff
Ensure move_importance() is non-zero
authorH. Felix Wittmann <hfwittmann@gmail.com>
Thu, 2 Jan 2014 12:00:48 +0000 (13:00 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 2 Jan 2014 12:01:24 +0000 (13:01 +0100)
In case ply is very high, function will round
to zero (although mathematically it is always
bigger than zero). On my system this happens at
movenumber 6661.

Although 6661 moves in a game is, of course,
probably impossible, for safety and to be locally
consistent makes sense to ensure returned value
is positive.

Non functional change.

src/timeman.cpp

index 9accfbb346a6e2ca77b960378a29a496c3ceeb4f..0348b677f4597ef5aaf3075b604e8f50e16a1e71 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include <algorithm>
 */
 
 #include <algorithm>
+#include <cfloat>
 #include <cmath>
 
 #include "search.h"
 #include <cmath>
 
 #include "search.h"
@@ -44,7 +45,7 @@ namespace {
 
   double move_importance(int ply) {
 
 
   double move_importance(int ply) {
 
-    return pow((1 + exp((ply - xshift) / xscale)), -skewfactor);
+    return pow((1 + exp((ply - xshift) / xscale)), -skewfactor) + DBL_MIN; // Ensure non-zero
   }
 
 
   }