Skip to content

Commit 7c30091

Browse files
Vizvezdenecsnicolet
authored andcommitted
Introduce ProbCut for check evasions
The idea of this patch can be described as follows: if we are in check and the transposition table move is a capture that returns a value far above beta, we can assume that the opponent just blundered a piece by giving check, and we return the transposition table value. This is similar to the usual probCut logic for quiet moves, but with a different threshold. Passed STC LLR: 2.94 (-2.94,2.94) {-0.25,1.25} Total: 33440 W: 3056 L: 2891 D: 27493 Ptnml(0-2): 110, 2338, 11672, 2477, 123 https://tests.stockfishchess.org/tests/view/602cd1087f517a561bc49bda Passed LTC LLR: 2.98 (-2.94,2.94) {0.25,1.25} Total: 10072 W: 401 L: 309 D: 9362 Ptnml(0-2): 2, 288, 4365, 378, 3 https://tests.stockfishchess.org/tests/view/602ceea57f517a561bc49bf0 The committed version has an additional fix to never return unproven wins in the tablebase range or the mate range. This fix passed tests for non- regression at STC and LTC: STC: LLR: 2.93 (-2.94,2.94) {-1.25,0.25} Total: 26240 W: 2354 L: 2280 D: 21606 Ptnml(0-2): 85, 1763, 9372, 1793, 107 https://tests.stockfishchess.org/tests/view/602d86a87f517a561bc49c7a LTC: LLR: 2.95 (-2.94,2.94) {-0.75,0.25} Total: 35304 W: 1299 L: 1256 D: 32749 Ptnml(0-2): 14, 1095, 15395, 1130, 18 https://tests.stockfishchess.org/tests/view/602d98d17f517a561bc49c83 Closes #3362 Bench: 3830215
1 parent 6294db7 commit 7c30091

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/search.cpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,23 @@ namespace {
969969

970970
moves_loop: // When in check, search starts from here
971971

972+
ttCapture = ttMove && pos.capture_or_promotion(ttMove);
973+
974+
// Step 11. A small Probcut idea, when we are in check
975+
probCutBeta = beta + 400;
976+
if ( ss->inCheck
977+
&& !PvNode
978+
&& depth >= 4
979+
&& ttCapture
980+
&& (tte->bound() & BOUND_LOWER)
981+
&& tte->depth() >= depth - 3
982+
&& ttValue >= probCutBeta
983+
&& abs(ttValue) <= VALUE_KNOWN_WIN
984+
&& abs(beta) <= VALUE_KNOWN_WIN
985+
)
986+
return probCutBeta;
987+
988+
972989
const PieceToHistory* contHist[] = { (ss-1)->continuationHistory, (ss-2)->continuationHistory,
973990
nullptr , (ss-4)->continuationHistory,
974991
nullptr , (ss-6)->continuationHistory };
@@ -985,12 +1002,11 @@ namespace {
9851002

9861003
value = bestValue;
9871004
singularQuietLMR = moveCountPruning = false;
988-
ttCapture = ttMove && pos.capture_or_promotion(ttMove);
9891005

9901006
// Mark this node as being searched
9911007
ThreadHolding th(thisThread, posKey, ss->ply);
9921008

993-
// Step 11. Loop through all pseudo-legal moves until no moves remain
1009+
// Step 12. Loop through all pseudo-legal moves until no moves remain
9941010
// or a beta cutoff occurs.
9951011
while ((move = mp.next_move(moveCountPruning)) != MOVE_NONE)
9961012
{
@@ -1036,7 +1052,7 @@ namespace {
10361052
// Calculate new depth for this move
10371053
newDepth = depth - 1;
10381054

1039-
// Step 12. Pruning at shallow depth (~200 Elo)
1055+
// Step 13. Pruning at shallow depth (~200 Elo)
10401056
if ( !rootNode
10411057
&& pos.non_pawn_material(us)
10421058
&& bestValue > VALUE_TB_LOSS_IN_MAX_PLY)
@@ -1084,7 +1100,7 @@ namespace {
10841100
}
10851101
}
10861102

1087-
// Step 13. Extensions (~75 Elo)
1103+
// Step 14. Extensions (~75 Elo)
10881104

10891105
// Singular extension search (~70 Elo). If all moves but one fail low on a
10901106
// search of (alpha-s, beta-s), and just one fails high on (alpha, beta),
@@ -1156,10 +1172,10 @@ namespace {
11561172
[movedPiece]
11571173
[to_sq(move)];
11581174

1159-
// Step 14. Make the move
1175+
// Step 15. Make the move
11601176
pos.do_move(move, st, givesCheck);
11611177

1162-
// Step 15. Reduced depth search (LMR, ~200 Elo). If the move fails high it will be
1178+
// Step 16. Reduced depth search (LMR, ~200 Elo). If the move fails high it will be
11631179
// re-searched at full depth.
11641180
if ( depth >= 3
11651181
&& moveCount > 1 + 2 * rootNode
@@ -1266,7 +1282,7 @@ namespace {
12661282
didLMR = false;
12671283
}
12681284

1269-
// Step 16. Full depth search when LMR is skipped or fails high
1285+
// Step 17. Full depth search when LMR is skipped or fails high
12701286
if (doFullDepthSearch)
12711287
{
12721288
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode);
@@ -1293,12 +1309,12 @@ namespace {
12931309
std::min(maxNextDepth, newDepth), false);
12941310
}
12951311

1296-
// Step 17. Undo move
1312+
// Step 18. Undo move
12971313
pos.undo_move(move);
12981314

12991315
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
13001316

1301-
// Step 18. Check for a new best move
1317+
// Step 19. Check for a new best move
13021318
// Finished searching the move. If a stop occurred, the return value of
13031319
// the search cannot be trusted, and we return immediately without
13041320
// updating best move, PV and TT.
@@ -1375,7 +1391,7 @@ namespace {
13751391
return VALUE_DRAW;
13761392
*/
13771393

1378-
// Step 19. Check for mate and stalemate
1394+
// Step 20. Check for mate and stalemate
13791395
// All legal moves have been searched and if there are no legal moves, it
13801396
// must be a mate or a stalemate. If we are in a singular extension search then
13811397
// return a fail low score.

0 commit comments

Comments
 (0)