Skip to content

Commit cc99284

Browse files
authored
Merge pull request official-stockfish#1361 from IIvec/master
nm
2 parents ff69d46 + d21e421 commit cc99284

File tree

3 files changed

+30
-43
lines changed

3 files changed

+30
-43
lines changed

src/movepick.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ enum StatsType { NoCaptures, Captures };
8484
/// unsuccessful during the current search, and is used for reduction and move
8585
/// ordering decisions. It uses 2 tables (one for each color) indexed by
8686
/// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards
87-
typedef Stats<int16_t, 10692, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)> ButterflyHistory;
87+
typedef Stats<int16_t, 13365, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)> ButterflyHistory;
8888

8989
/// At higher depths LowPlyHistory records successful quiet moves near the root
9090
/// and quiet moves which are/were in the PV (ttPv). It is cleared with each new

src/pawns.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ namespace {
3030
#define S(mg, eg) make_score(mg, eg)
3131

3232
// Pawn penalties
33-
constexpr Score Backward = S( 8, 25);
34-
constexpr Score Doubled = S(10, 55);
35-
constexpr Score Isolated = S( 3, 15);
36-
constexpr Score WeakLever = S( 3, 55);
37-
constexpr Score WeakUnopposed = S(13, 25);
33+
constexpr Score Backward = S( 6, 23);
34+
constexpr Score Doubled = S(13, 53);
35+
constexpr Score Isolated = S( 2, 15);
36+
constexpr Score WeakLever = S( 5, 57);
37+
constexpr Score WeakUnopposed = S(16, 22);
3838

3939
// Bonus for blocked pawns at 5th or 6th rank
4040
constexpr Score BlockedPawn[2] = { S(-15, -3), S(-6, 3) };
@@ -69,8 +69,8 @@ namespace {
6969

7070
// KingOnFile[semi-open Us][semi-open Them] contains bonuses/penalties
7171
// for king when the king is on a semi-open or open file.
72-
constexpr Score KingOnFile[2][2] = {{ S(-19,12), S(-6, 7) },
73-
{ S( 0, 2), S( 6,-5) }};
72+
constexpr Score KingOnFile[2][2] = {{ S(-21,10), S(-7, 1) },
73+
{ S( 0,-3), S( 9,-4) }};
7474

7575
#undef S
7676
#undef V
@@ -172,7 +172,7 @@ namespace {
172172

173173
else if (backward)
174174
score -= Backward
175-
+ WeakUnopposed * !opposed;
175+
+ WeakUnopposed * !opposed * bool(~(FileABB | FileHBB) & s);
176176

177177
if (!support)
178178
score -= Doubled * doubled

src/search.cpp

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ namespace {
6262
constexpr uint64_t TtHitAverageWindow = 4096;
6363
constexpr uint64_t TtHitAverageResolution = 1024;
6464

65-
// Razor and futility margins
66-
constexpr int RazorMargin = 510;
65+
// Futility margin
6766
Value futility_margin(Depth d, bool improving) {
6867
return Value(234 * (d - improving));
6968
}
@@ -83,7 +82,7 @@ namespace {
8382

8483
// History and stats update bonus, based on depth
8584
int stat_bonus(Depth d) {
86-
return d > 13 ? 29 : 17 * d * d + 134 * d - 134;
85+
return d > 14 ? 29 : 8 * d * d + 224 * d - 215;
8786
}
8887

8988
// Add a small random component to draw evaluations to avoid 3fold-blindness
@@ -829,12 +828,6 @@ namespace {
829828
thisThread->mainHistory[~us][from_to((ss-1)->currentMove)] << bonus;
830829
}
831830

832-
// Step 7. Razoring (~1 Elo)
833-
if ( !rootNode // The required rootNode PV handling is not available in qsearch
834-
&& depth == 1
835-
&& eval <= alpha - RazorMargin)
836-
return qsearch<NT>(pos, ss, alpha, beta);
837-
838831
// Set up improving flag that is used in various pruning heuristics
839832
// We define position as improving if static evaluation of position is better
840833
// Than the previous static evaluation at our turn
@@ -843,14 +836,14 @@ namespace {
843836
? ss->staticEval > (ss-4)->staticEval || (ss-4)->staticEval == VALUE_NONE
844837
: ss->staticEval > (ss-2)->staticEval;
845838

846-
// Step 8. Futility pruning: child node (~50 Elo)
839+
// Step 7. Futility pruning: child node (~50 Elo)
847840
if ( !PvNode
848-
&& depth < 8
841+
&& depth < 9
849842
&& eval - futility_margin(depth, improving) >= beta
850843
&& eval < VALUE_KNOWN_WIN) // Do not return unproven wins
851844
return eval;
852845

853-
// Step 9. Null move search with verification search (~40 Elo)
846+
// Step 8. Null move search with verification search (~40 Elo)
854847
if ( !PvNode
855848
&& (ss-1)->currentMove != MOVE_NULL
856849
&& (ss-1)->statScore < 22977
@@ -901,9 +894,9 @@ namespace {
901894
}
902895
}
903896

904-
probCutBeta = beta + 183 - 49 * improving;
897+
probCutBeta = beta + 194 - 49 * improving;
905898

906-
// Step 10. ProbCut (~10 Elo)
899+
// Step 9. ProbCut (~10 Elo)
907900
// If we have a good enough capture and a reduced search returns a value
908901
// much above beta, we can (almost) safely prune the previous move.
909902
if ( !PvNode
@@ -976,7 +969,7 @@ namespace {
976969
ss->ttPv = ttPv;
977970
}
978971

979-
// Step 11. If the position is not in TT, decrease depth by 2
972+
// Step 10. If the position is not in TT, decrease depth by 2
980973
if ( PvNode
981974
&& depth >= 6
982975
&& !ttMove)
@@ -1005,7 +998,7 @@ namespace {
1005998
// Mark this node as being searched
1006999
ThreadHolding th(thisThread, posKey, ss->ply);
10071000

1008-
// Step 12. Loop through all pseudo-legal moves until no moves remain
1001+
// Step 11. Loop through all pseudo-legal moves until no moves remain
10091002
// or a beta cutoff occurs.
10101003
while ((move = mp.next_move(moveCountPruning)) != MOVE_NONE)
10111004
{
@@ -1043,7 +1036,7 @@ namespace {
10431036
// Calculate new depth for this move
10441037
newDepth = depth - 1;
10451038

1046-
// Step 13. Pruning at shallow depth (~200 Elo)
1039+
// Step 12. Pruning at shallow depth (~200 Elo)
10471040
if ( !rootNode
10481041
&& pos.non_pawn_material(us)
10491042
&& bestValue > VALUE_TB_LOSS_IN_MAX_PLY)
@@ -1066,11 +1059,11 @@ namespace {
10661059
// Futility pruning: parent node (~5 Elo)
10671060
if ( lmrDepth < 7
10681061
&& !ss->inCheck
1069-
&& ss->staticEval + 266 + 170 * lmrDepth <= alpha
1062+
&& ss->staticEval + 254 + 159 * lmrDepth <= alpha
10701063
&& (*contHist[0])[movedPiece][to_sq(move)]
10711064
+ (*contHist[1])[movedPiece][to_sq(move)]
10721065
+ (*contHist[3])[movedPiece][to_sq(move)]
1073-
+ (*contHist[5])[movedPiece][to_sq(move)] / 2 < 27376)
1066+
+ (*contHist[5])[movedPiece][to_sq(move)] / 2 < 26394)
10741067
continue;
10751068

10761069
// Prune moves with negative SEE (~20 Elo)
@@ -1086,12 +1079,12 @@ namespace {
10861079
continue;
10871080

10881081
// SEE based pruning
1089-
if (!pos.see_ge(move, Value(-213) * depth)) // (~25 Elo)
1082+
if (!pos.see_ge(move, Value(-218) * depth)) // (~25 Elo)
10901083
continue;
10911084
}
10921085
}
10931086

1094-
// Step 14. Extensions (~75 Elo)
1087+
// Step 13. Extensions (~75 Elo)
10951088

10961089
// Singular extension search (~70 Elo). If all moves but one fail low on a
10971090
// search of (alpha-s, beta-s), and just one fails high on (alpha, beta),
@@ -1150,12 +1143,6 @@ namespace {
11501143
&& pos.non_pawn_material() <= 2 * RookValueMg)
11511144
extension = 1;
11521145

1153-
// Late irreversible move extension
1154-
if ( move == ttMove
1155-
&& pos.rule50_count() > 80
1156-
&& (captureOrPromotion || type_of(movedPiece) == PAWN))
1157-
extension = 2;
1158-
11591146
// Add extension to new depth
11601147
newDepth += extension;
11611148

@@ -1169,18 +1156,18 @@ namespace {
11691156
[movedPiece]
11701157
[to_sq(move)];
11711158

1172-
// Step 15. Make the move
1159+
// Step 14. Make the move
11731160
pos.do_move(move, st, givesCheck);
11741161

1175-
// Step 16. Reduced depth search (LMR, ~200 Elo). If the move fails high it will be
1162+
// Step 15. Reduced depth search (LMR, ~200 Elo). If the move fails high it will be
11761163
// re-searched at full depth.
11771164
if ( depth >= 3
11781165
&& moveCount > 1 + 2 * rootNode
11791166
&& ( !captureOrPromotion
11801167
|| moveCountPruning
11811168
|| ss->staticEval + PieceValue[EG][pos.captured_piece()] <= alpha
11821169
|| cutNode
1183-
|| (!PvNode && !formerPv)
1170+
|| (!PvNode && !formerPv && thisThread->captureHistory[movedPiece][to_sq(move)][type_of(pos.captured_piece())] < 4506)
11841171
|| thisThread->ttHitAverage < 432 * TtHitAverageResolution * TtHitAverageWindow / 1024))
11851172
{
11861173
Depth r = reduction(improving, depth, moveCount);
@@ -1272,7 +1259,7 @@ namespace {
12721259
didLMR = false;
12731260
}
12741261

1275-
// Step 17. Full depth search when LMR is skipped or fails high
1262+
// Step 16. Full depth search when LMR is skipped or fails high
12761263
if (doFullDepthSearch)
12771264
{
12781265
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode);
@@ -1299,12 +1286,12 @@ namespace {
12991286
std::min(maxNextDepth, newDepth), false);
13001287
}
13011288

1302-
// Step 18. Undo move
1289+
// Step 17. Undo move
13031290
pos.undo_move(move);
13041291

13051292
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
13061293

1307-
// Step 19. Check for a new best move
1294+
// Step 18. Check for a new best move
13081295
// Finished searching the move. If a stop occurred, the return value of
13091296
// the search cannot be trusted, and we return immediately without
13101297
// updating best move, PV and TT.
@@ -1381,7 +1368,7 @@ namespace {
13811368
return VALUE_DRAW;
13821369
*/
13831370

1384-
// Step 20. Check for mate and stalemate
1371+
// Step 19. Check for mate and stalemate
13851372
// All legal moves have been searched and if there are no legal moves, it
13861373
// must be a mate or a stalemate. If we are in a singular extension search then
13871374
// return a fail low score.

0 commit comments

Comments
 (0)