1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 09:13:08 +00:00

Use less reduction for escaping moves

This patch reuses the threatenedPieces variable (which is calculated in movepicker)
to reduce less in the search tree the moves which escape a capture.

passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 314352 W: 84042 L: 83328 D: 146982
Ptnml(0-2): 1105, 35084, 84207, 35552, 1228
https://tests.stockfishchess.org/tests/view/63355f37a004bed9a2e4a17f

passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 90752 W: 24556 L: 24147 D: 42049
Ptnml(0-2): 59, 8855, 27123, 9296, 43
https://tests.stockfishchess.org/tests/view/63383a7735f43d649ff5fa8b

closes https://github.com/official-stockfish/Stockfish/pull/4181

bench: 4114228
This commit is contained in:
disservin 2022-09-18 11:16:54 +02:00 committed by Stéphane Nicolet
parent 232bf19be4
commit f436bf77ad
6 changed files with 21 additions and 15 deletions

View file

@ -69,6 +69,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
stage = (pos.checkers() ? EVASION_TT : MAIN_TT) + stage = (pos.checkers() ? EVASION_TT : MAIN_TT) +
!(ttm && pos.pseudo_legal(ttm)); !(ttm && pos.pseudo_legal(ttm));
threatenedPieces = 0;
} }
/// MovePicker constructor for quiescence search /// MovePicker constructor for quiescence search
@ -106,19 +107,17 @@ void MovePicker::score() {
static_assert(Type == CAPTURES || Type == QUIETS || Type == EVASIONS, "Wrong type"); static_assert(Type == CAPTURES || Type == QUIETS || Type == EVASIONS, "Wrong type");
[[maybe_unused]] Bitboard threatened, threatenedByPawn, threatenedByMinor, threatenedByRook; [[maybe_unused]] Bitboard threatenedByPawn, threatenedByMinor, threatenedByRook;
if constexpr (Type == QUIETS) if constexpr (Type == QUIETS)
{ {
Color us = pos.side_to_move(); Color us = pos.side_to_move();
// squares threatened by pawns
threatenedByPawn = pos.attacks_by<PAWN>(~us); threatenedByPawn = pos.attacks_by<PAWN>(~us);
// squares threatened by minors or pawns
threatenedByMinor = pos.attacks_by<KNIGHT>(~us) | pos.attacks_by<BISHOP>(~us) | threatenedByPawn; threatenedByMinor = pos.attacks_by<KNIGHT>(~us) | pos.attacks_by<BISHOP>(~us) | threatenedByPawn;
// squares threatened by rooks, minors or pawns
threatenedByRook = pos.attacks_by<ROOK>(~us) | threatenedByMinor; threatenedByRook = pos.attacks_by<ROOK>(~us) | threatenedByMinor;
// pieces threatened by pieces of lesser material value // Pieces threatened by pieces of lesser material value
threatened = (pos.pieces(us, QUEEN) & threatenedByRook) threatenedPieces = (pos.pieces(us, QUEEN) & threatenedByRook)
| (pos.pieces(us, ROOK) & threatenedByMinor) | (pos.pieces(us, ROOK) & threatenedByMinor)
| (pos.pieces(us, KNIGHT, BISHOP) & threatenedByPawn); | (pos.pieces(us, KNIGHT, BISHOP) & threatenedByPawn);
} }
@ -134,7 +133,7 @@ void MovePicker::score() {
+ (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)] + (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
+ (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)] + (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
+ (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)] + (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)]
+ (threatened & from_sq(m) ? + (threatenedPieces & from_sq(m) ?
(type_of(pos.moved_piece(m)) == QUEEN && !(to_sq(m) & threatenedByRook) ? 50000 (type_of(pos.moved_piece(m)) == QUEEN && !(to_sq(m) & threatenedByRook) ? 50000
: type_of(pos.moved_piece(m)) == ROOK && !(to_sq(m) & threatenedByMinor) ? 25000 : type_of(pos.moved_piece(m)) == ROOK && !(to_sq(m) & threatenedByMinor) ? 25000
: !(to_sq(m) & threatenedByPawn) ? 15000 : !(to_sq(m) & threatenedByPawn) ? 15000

View file

@ -131,6 +131,8 @@ public:
MovePicker(const Position&, Move, Value, Depth, const CapturePieceToHistory*); MovePicker(const Position&, Move, Value, Depth, const CapturePieceToHistory*);
Move next_move(bool skipQuiets = false); Move next_move(bool skipQuiets = false);
Bitboard threatenedPieces;
private: private:
template<PickType T, typename Pred> Move select(Pred); template<PickType T, typename Pred> Move select(Pred);
template<GenType> void score(); template<GenType> void score();

View file

@ -789,7 +789,7 @@ namespace {
&& depth < 8 && depth < 8
&& eval - futility_margin(depth, improving) - (ss-1)->statScore / 303 >= beta && eval - futility_margin(depth, improving) - (ss-1)->statScore / 303 >= beta
&& eval >= beta && eval >= beta
&& eval < 28031) // larger than VALUE_KNOWN_WIN, but smaller than TB wins. && eval < 28031) // larger than VALUE_KNOWN_WIN, but smaller than TB wins
return eval; return eval;
// Step 9. Null move search with verification search (~22 Elo) // Step 9. Null move search with verification search (~22 Elo)
@ -1163,7 +1163,12 @@ moves_loop: // When in check, search starts here
if (singularQuietLMR) if (singularQuietLMR)
r--; r--;
// Increase reduction if next ply has a lot of fail high else reset count to 0 // Dicrease reduction if we move a threatened piece (~1 Elo)
if ( depth > 9
&& (mp.threatenedPieces & from_sq(move)))
r--;
// Increase reduction if next ply has a lot of fail high
if ((ss+1)->cutoffCnt > 3 && !PvNode) if ((ss+1)->cutoffCnt > 3 && !PvNode)
r++; r++;