int Reductions[MAX_MOVES]; // [depth or moveNumber]
Depth reduction(bool i, Depth d, int mn) {
- int r = Reductions[d / ONE_PLY] * Reductions[mn] / 1024;
+ int r = Reductions[d / ONE_PLY] * Reductions[mn];
return ((r + 512) / 1024 + (!i && r > 1024)) * ONE_PLY;
}
void Search::init() {
for (int i = 1; i < MAX_MOVES; ++i)
- Reductions[i] = int(1024 * std::log(i) / std::sqrt(1.95));
+ Reductions[i] = int(22.9 * std::log(i));
}
for (Thread* th: Threads)
minScore = std::min(minScore, th->rootMoves[0].score);
- // Vote according to score and depth
+ // Vote according to score and depth, and select the best thread
+ int64_t bestVote = 0;
for (Thread* th : Threads)
{
- int64_t s = th->rootMoves[0].score - minScore + 1;
- votes[th->rootMoves[0].pv[0]] += 200 + s * s * int(th->completedDepth);
- }
+ votes[th->rootMoves[0].pv[0]] +=
+ (th->rootMoves[0].score - minScore + 14) * int(th->completedDepth);
- // Select best thread
- auto bestVote = votes[this->rootMoves[0].pv[0]];
- for (Thread* th : Threads)
if (votes[th->rootMoves[0].pv[0]] > bestVote)
{
bestVote = votes[th->rootMoves[0].pv[0]];
bestThread = th;
}
+ }
}
previousScore = bestThread->rootMoves[0].score;
beta = (alpha + beta) / 2;
alpha = std::max(bestValue - delta, -VALUE_INFINITE);
+ failedHighCnt = 0;
if (mainThread)
- {
- failedHighCnt = 0;
mainThread->stopOnPonderhit = false;
- }
}
else if (bestValue >= beta)
{
beta = std::min(bestValue + delta, VALUE_INFINITE);
- if (mainThread)
- ++failedHighCnt;
+ ++failedHighCnt;
}
else
break;
ttValue = ttHit ? value_from_tt(tte->value(), ss->ply) : VALUE_NONE;
ttMove = rootNode ? thisThread->rootMoves[thisThread->pvIdx].pv[0]
: ttHit ? tte->move() : MOVE_NONE;
- ttPv = (ttHit && tte->is_pv()) || (PvNode && depth > 4 * ONE_PLY);
+ ttPv = PvNode || (ttHit && tte->is_pv());
// At non-PV nodes we check for an early TT cutoff
if ( !PvNode
value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
moveCountPruning = false;
ttCapture = ttMove && pos.capture_or_promotion(ttMove);
+ int singularExtensionLMRmultiplier = 0;
// Step 12. Loop through all pseudo-legal moves until no moves remain
// or a beta cutoff occurs.
ss->excludedMove = MOVE_NONE;
if (value < singularBeta)
+ {
extension = ONE_PLY;
+ singularExtensionLMRmultiplier++;
+ if (value < singularBeta - std::min(3 * depth / ONE_PLY, 39))
+ singularExtensionLMRmultiplier++;
+ }
// Multi-cut pruning
// Our ttMove is assumed to fail high, and now we failed high also on a reduced
if ( !captureOrPromotion
&& !givesCheck
- && !pos.advanced_pawn_push(move))
+ && (!pos.advanced_pawn_push(move) || pos.non_pawn_material(~us) > BishopValueMg))
{
// Move count based pruning (~30 Elo)
if (moveCountPruning)
if (!pos.see_ge(move, Value(-29 * lmrDepth * lmrDepth)))
continue;
}
- else if (!pos.see_ge(move, -PawnValueEg * (depth / ONE_PLY))) // (~20 Elo)
+ else if ((!givesCheck || !(pos.blockers_for_king(~us) & from_sq(move)))
+ && !pos.see_ge(move, -PawnValueEg * (depth / ONE_PLY))) // (~20 Elo)
continue;
}
// Decrease reduction if opponent's move count is high (~10 Elo)
if ((ss-1)->moveCount > 15)
r -= ONE_PLY;
+ // Decrease reduction if move has been singularly extended
+ r -= singularExtensionLMRmultiplier * ONE_PLY;
if (!captureOrPromotion)
{