Skip to content

Commit 8454d87

Browse files
hfwittmannmcostalba
authored andcommitted
Ensure move_importance() is non-zero
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.
1 parent 153309e commit 8454d87

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/timeman.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#include <algorithm>
21+
#include <cfloat>
2122
#include <cmath>
2223

2324
#include "search.h"
@@ -44,7 +45,7 @@ namespace {
4445

4546
double move_importance(int ply) {
4647

47-
return pow((1 + exp((ply - xshift) / xscale)), -skewfactor);
48+
return pow((1 + exp((ply - xshift) / xscale)), -skewfactor) + DBL_MIN; // Ensure non-zero
4849
}
4950

5051

0 commit comments

Comments
 (0)