Skip to content

Commit

Permalink
Ensure move_importance() is non-zero
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hfwittmann authored and mcostalba committed Jan 2, 2014
1 parent 153309e commit 8454d87
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/timeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include <algorithm>
#include <cfloat>
#include <cmath>

#include "search.h"
Expand All @@ -44,7 +45,7 @@ namespace {

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
}


Expand Down

0 comments on commit 8454d87

Please sign in to comment.