// History and stats update bonus, based on depth
int stat_bonus(Depth depth) {
int d = depth / ONE_PLY;
- return d > 17 ? 0 : 32 * d * d + 64 * d - 64;
+ return d > 17 ? 0 : 33 * d * d + 66 * d - 66;
}
// Skill structure is used to implement strength limit
std::memset(ss-4, 0, 7 * sizeof(Stack));
for (int i = 4; i > 0; i--)
- (ss-i)->contHistory = this->contHistory[NO_PIECE][0].get(); // Use as sentinel
+ (ss-i)->continuationHistory = this->continuationHistory[NO_PIECE][0].get(); // Use as sentinel
bestValue = delta = alpha = -VALUE_INFINITE;
beta = VALUE_INFINITE;
(ss+1)->ply = ss->ply + 1;
ss->currentMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
- ss->contHistory = thisThread->contHistory[NO_PIECE][0].get();
+ ss->continuationHistory = thisThread->continuationHistory[NO_PIECE][0].get();
(ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
Square prevSq = to_sq((ss-1)->currentMove);
Depth R = ((823 + 67 * depth / ONE_PLY) / 256 + std::min((eval - beta) / PawnValueMg, 3)) * ONE_PLY;
ss->currentMove = MOVE_NULL;
- ss->contHistory = thisThread->contHistory[NO_PIECE][0].get();
+ ss->continuationHistory = thisThread->continuationHistory[NO_PIECE][0].get();
pos.do_null_move(st);
probCutCount++;
ss->currentMove = move;
- ss->contHistory = thisThread->contHistory[pos.moved_piece(move)][to_sq(move)].get();
+ ss->continuationHistory = thisThread->continuationHistory[pos.moved_piece(move)][to_sq(move)].get();
assert(depth >= 5 * ONE_PLY);
moves_loop: // When in check, search starts from here
- const PieceToHistory* contHist[] = { (ss-1)->contHistory, (ss-2)->contHistory, nullptr, (ss-4)->contHistory };
+ const PieceToHistory* contHist[] = { (ss-1)->continuationHistory, (ss-2)->continuationHistory, nullptr, (ss-4)->continuationHistory };
Move countermove = thisThread->counterMoves[pos.piece_on(prevSq)][prevSq];
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
int lmrDepth = std::max(newDepth - reduction<PvNode>(improving, depth, moveCount), DEPTH_ZERO) / ONE_PLY;
// Countermoves based pruning (~20 Elo)
- if ( lmrDepth < 3
+ if ( lmrDepth < 3 + ((ss-1)->statScore > 0)
&& (*contHist[0])[movedPiece][to_sq(move)] < CounterMovePruneThreshold
&& (*contHist[1])[movedPiece][to_sq(move)] < CounterMovePruneThreshold)
continue;
// Update the current move (this must be done after singular extension search)
ss->currentMove = move;
- ss->contHistory = thisThread->contHistory[movedPiece][to_sq(move)].get();
+ ss->continuationHistory = thisThread->continuationHistory[movedPiece][to_sq(move)].get();
// Step 15. Make the move
pos.do_move(move, st, givesCheck);
if (captureOrPromotion) // (~5 Elo)
{
- // Increase reduction by comparing opponent's stat score
- if ((ss-1)->statScore >= 0)
- r += ONE_PLY;
-
- r -= r ? ONE_PLY : DEPTH_ZERO;
+ // Decrease reduction by comparing opponent's stat score
+ if ((ss-1)->statScore < 0)
+ r -= ONE_PLY;
}
else
{
r += ONE_PLY;
// Decrease/increase reduction for moves with a good/bad history (~30 Elo)
- r = std::max(DEPTH_ZERO, (r / ONE_PLY - ss->statScore / 20000) * ONE_PLY);
+ r -= ss->statScore / 20000 * ONE_PLY;
}
- Depth d = std::max(newDepth - r, ONE_PLY);
+ Depth d = std::max(newDepth - std::max(r, DEPTH_ZERO), ONE_PLY);
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d, true);
ss->pv[0] = MOVE_NONE;
}
+ Thread* thisThread = pos.this_thread();
(ss+1)->ply = ss->ply + 1;
ss->currentMove = bestMove = MOVE_NONE;
+ ss->continuationHistory = thisThread->continuationHistory[NO_PIECE][0].get();
inCheck = pos.checkers();
moveCount = 0;
futilityBase = bestValue + 128;
}
+ const PieceToHistory* contHist[] = { (ss-1)->continuationHistory, (ss-2)->continuationHistory, nullptr, (ss-4)->continuationHistory };
+
// Initialize a MovePicker object for the current position, and prepare
// to search the moves. Because the depth is <= 0 here, only captures,
// queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
// be generated.
- MovePicker mp(pos, ttMove, depth, &pos.this_thread()->mainHistory,
- &pos.this_thread()->captureHistory,
+ MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
+ &thisThread->captureHistory,
+ contHist,
to_sq((ss-1)->currentMove));
// Loop through the moves until no moves remain or a beta cutoff occurs
}
ss->currentMove = move;
+ ss->continuationHistory = thisThread->continuationHistory[pos.moved_piece(move)][to_sq(move)].get();
// Make and search the move
pos.do_move(move, st, givesCheck);
for (int i : {1, 2, 4})
if (is_ok((ss-i)->currentMove))
- (*(ss-i)->contHistory)[pc][to] << bonus;
+ (*(ss-i)->continuationHistory)[pc][to] << bonus;
}