diff options
Diffstat (limited to 'src/root.c')
| -rwxr-xr-x | src/root.c | 56 |
1 files changed, 37 insertions, 19 deletions
@@ -950,27 +950,45 @@ _IterateSetSearchGlobals(ULONG uDepth) // g_uSoftExtendLimit = g_uIterateDepth * 2; g_uHardExtendLimit = g_uIterateDepth * 4; - for (u = 0; u < MAX_PLY_PER_SEARCH; u++) + + // g_uExtensionReduction[]'s own bands, below, must stay reachable + // within [0, MAX_PLY_PER_SEARCH) regardless of how deep g_uIterateDepth + // is -- naive g_uSoftExtendLimit/g_uHardExtendLimit (2x/4x iterate + // depth) can hugely exceed MAX_PLY_PER_SEARCH for a deep requested + // search (e.g. sd=30 -> hard limit 120 >> 64), which would leave every + // reachable u in the loop below permanently in the "0 penalty" band -- + // no taper at all for the entire representable ply range. Deliberately + // a LOCAL, separately-capped depth for this table only -- + // g_uSoftExtendLimit/g_uHardExtendLimit themselves stay uncapped (raw + // g_uIterateDepth * 2/4) since g_uHardExtendLimit is also read directly + // elsewhere (searchsup.c's QSearch runaway-depth cutoff) where capping + // it would be an unrelated, unintended behavior change. { - if (u < g_uSoftExtendLimit) - { - g_uExtensionReduction[u] = 0; - } - else if (u < (g_uSoftExtendLimit + g_uIterateDepth / 2)) - { - g_uExtensionReduction[u] = QUARTER_PLY; - } - else if (u < (g_uSoftExtendLimit + g_uIterateDepth)) - { - g_uExtensionReduction[u] = HALF_PLY; - } - else if (u < g_uHardExtendLimit) - { - g_uExtensionReduction[u] = THREE_QUARTERS_PLY; - } - else + ULONG uEffIterateDepth = MIN(g_uIterateDepth, (MAX_PLY_PER_SEARCH - 4) / 4); + ULONG uEffSoftLimit = uEffIterateDepth * 2; + ULONG uEffHardLimit = uEffIterateDepth * 4; + for (u = 0; u < MAX_PLY_PER_SEARCH; u++) { - g_uExtensionReduction[u] = 5 * ONE_PLY; + if (u < uEffSoftLimit) + { + g_uExtensionReduction[u] = 0; + } + else if (u < (uEffSoftLimit + uEffIterateDepth / 2)) + { + g_uExtensionReduction[u] = QUARTER_PLY; + } + else if (u < (uEffSoftLimit + uEffIterateDepth)) + { + g_uExtensionReduction[u] = HALF_PLY; + } + else if (u < uEffHardLimit) + { + g_uExtensionReduction[u] = THREE_QUARTERS_PLY; + } + else + { + g_uExtensionReduction[u] = 5 * ONE_PLY; + } } } |
