zullil wrote:Dann Corbit wrote:
First version (I think it turns out better):
Code: Select all
#ifdef SMOOTH_REDUCTION
double delta = approximateEval - beta;
delta = max(delta, 1.0);
double ddepth = double(depth);
double r = 0.18 * ddepth + 3.1 + log(delta)/5.0;
r = r > ddepth ? ddepth : r;
int R = int(r);
#else
// Null move dynamic reduction based on depth
int R = (depth >= 5 * OnePly ? 4 : 3);
// Null move dynamic reduction based on value
if (approximateEval - beta > PawnValueMidgame)
R++;
#endif
nullValue = -search(pos, ss, -(beta-1), depth-R*OnePly, ply+1, false, threadID);
Second version:
Code: Select all
#ifdef SMOOTH_REDUCTION
double delta = approximateEval - beta;
delta = max(delta, 1.0);
double ddepth = double(depth);
double r = 0.18 * ddepth + 3.1 + log(delta)/5.0;
r = r > ddepth ? ddepth : r;
int R = int(r * (int)OnePly);
#else
// Null move dynamic reduction based on depth
int R = (depth >= 5 * OnePly ? 4 : 3);
// Null move dynamic reduction based on value
if (approximateEval - beta > PawnValueMidgame)
R++;
R *= OnePly;
#endif
nullValue = -search(pos, ss, -(beta-1), depth-R, ply+1, false, threadID);
max should be Max, right?
Some C++ systems will not have macro max(a,b) defined.
So there is another macro in misc.h which is intended to be portable:
misc.h ( 40): #define Max(x, y) (((x) < (y))? (y) : (x))
So, indeed, the choice of Max() over max() is better.
We could include header <algorithm> in C++ which has the following:
template<class T> const T& max(const T& a, const T& b);
template<class T, class Compare>
const T& max(const T& a, const T& b, Compare comp);
however, older C++ compilers might want <algorithm.h> and C++ compliance is a bit more spotty than C compliance in many cases. So it is safer to declare our own macro with a case difference.