mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 02:47:45 +00:00
Optimize attackers_to()
https://tests.stockfishchess.org/tests/view/6782decb6ddf09c0b4b6e1b0 LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 105920 W: 27571 L: 27181 D: 51168 Ptnml(0-2): 284, 10808, 30403, 11164, 301 - If we only need to know if attackers exist we can skip some calculations. - Also calculating slider/magic attackers first is better because the double lookup is slow due to memory latency. - I also included a couple of very minor cleanups in search that probably don't warrant their own PR but I can open separately if that's better. closes https://github.com/official-stockfish/Stockfish/pull/5762 No functional change
This commit is contained in:
+4
-4
@@ -77,7 +77,7 @@ constexpr int futility_move_count(bool improving, Depth depth) {
|
||||
return (3 + depth * depth) / (2 - improving);
|
||||
}
|
||||
|
||||
int correction_value(const Worker& w, const Position& pos, Stack* ss) {
|
||||
int correction_value(const Worker& w, const Position& pos, const Stack* ss) {
|
||||
const Color us = pos.side_to_move();
|
||||
const auto m = (ss - 1)->currentMove;
|
||||
const auto pcv = w.pawnCorrectionHistory[us][pawn_structure_index<Correction>(pos)];
|
||||
@@ -1140,7 +1140,7 @@ moves_loop: // When in check, search starts here
|
||||
|
||||
// Decrease reduction if position is or has been on the PV (~7 Elo)
|
||||
if (ss->ttPv)
|
||||
r -= 1024 + (ttData.value > alpha) * 1024 + (ttData.depth >= depth) * 1024;
|
||||
r -= 1024 + ((ttData.value > alpha) + (ttData.depth >= depth)) * 1024;
|
||||
|
||||
// Decrease reduction for PvNodes (~0 Elo on STC, ~2 Elo on LTC)
|
||||
if (PvNode)
|
||||
@@ -1423,8 +1423,8 @@ moves_loop: // When in check, search starts here
|
||||
&& ((bestValue < ss->staticEval && bestValue < beta) // negative correction & no fail high
|
||||
|| (bestValue > ss->staticEval && bestMove))) // positive correction & no fail low
|
||||
{
|
||||
const auto m = (ss - 1)->currentMove;
|
||||
static const int nonPawnWeight = 154;
|
||||
const auto m = (ss - 1)->currentMove;
|
||||
constexpr int nonPawnWeight = 154;
|
||||
|
||||
auto bonus = std::clamp(int(bestValue - ss->staticEval) * depth / 8,
|
||||
-CORRECTION_HISTORY_LIMIT / 4, CORRECTION_HISTORY_LIMIT / 4);
|
||||
|
||||
Reference in New Issue
Block a user