int MapA1D1D4[SQUARE_NB];
int MapKK[10][SQUARE_NB]; // [MapA1D1D4][SQUARE_NB]
-int Binomial[6][SQUARE_NB]; // [k][n] k elements from a set of n elements
+int Binomial[7][SQUARE_NB]; // [k][n] k elements from a set of n elements
int LeadPawnIdx[6][SQUARE_NB]; // [leadPawnsCnt][SQUARE_NB]
int LeadPawnsSize[6][4]; // [leadPawnsCnt][FILE_A..FILE_D]
Binomial[0][0] = 1;
for (int n = 1; n < 64; n++) // Squares
- for (int k = 0; k < 6 && k <= n; ++k) // Pieces
+ for (int k = 0; k < 7 && k <= n; ++k) // Pieces
Binomial[k][n] = (k > 0 ? Binomial[k - 1][n - 1] : 0)
+ (k < n ? Binomial[k ][n - 1] : 0);
WDLScore wdl = -probe_wdl(pos, &result);
dtz = dtz_before_zeroing(wdl);
}
+ else if (pos.is_draw(1))
+ {
+ // In case a root move leads to a draw by repetition or
+ // 50-move rule, we set dtz to zero. Note: since we are
+ // only 1 ply from the root, this must be a true 3-fold
+ // repetition inside the game history.
+ dtz = 0;
+ }
else
{
// Otherwise, take dtz for the new position and correct by 1 ply
ProbeState result;
StateInfo st;
+ WDLScore wdl;
bool rule50 = Options["Syzygy50MoveRule"];
{
pos.do_move(m.pv[0], st);
- WDLScore wdl = -probe_wdl(pos, &result);
+ if (pos.is_draw(1))
+ wdl = WDLDraw;
+ else
+ wdl = -probe_wdl(pos, &result);
pos.undo_move(m.pv[0]);