if (history[p][to] >= HistoryMax)
for (int i = 0; i < 16; i++)
for (int j = 0; j < 64; j++)
- history[i][j] /= 4;
+ history[i][j] /= 2;
}
assert(square_is_ok(to));
history[p][to] -= int(d) * int(d);
- if (history[p][to] < 0)
- history[p][to] = 0;
+
+ // Prevent history underflow
+ if (history[p][to] <= -HistoryMax)
+ for (int i = 0; i < 16; i++)
+ for (int j = 0; j < 64; j++)
+ history[i][j] /= 2;
}