Skip to content

Commit 472de89

Browse files
VoyagerOnesnicolet
authored andcommitted
Current capture for Counter-Move history
Use current capture to index the CMH table instead of prior capture. STC: LLR: 2.96 (-2.94,2.94) [0.00,4.00] Total: 61908 W: 13626 L: 13220 D: 35062 http://tests.stockfishchess.org/tests/view/5da8aa670ebc597ba8eda558 LTC: LLR: 2.96 (-2.94,2.94) [0.00,4.00] Total: 49057 W: 8071 L: 7765 D: 33221 http://tests.stockfishchess.org/tests/view/5da8e99d0ebc597ba8eda9ca Closes #2362 Bench: 4423737
1 parent b8e5092 commit 472de89

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/search.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -864,12 +864,17 @@ namespace {
864864
&& probCutCount < 2 + 2 * cutNode)
865865
if (move != excludedMove && pos.legal(move))
866866
{
867+
assert(pos.capture_or_promotion(move));
868+
assert(depth >= 5);
869+
870+
captureOrPromotion = true;
867871
probCutCount++;
868872

869873
ss->currentMove = move;
870-
ss->continuationHistory = &thisThread->continuationHistory[inCheck][priorCapture][pos.moved_piece(move)][to_sq(move)];
871-
872-
assert(depth >= 5);
874+
ss->continuationHistory = &thisThread->continuationHistory[inCheck]
875+
[captureOrPromotion]
876+
[pos.moved_piece(move)]
877+
[to_sq(move)];
873878

874879
pos.do_move(move, st);
875880

@@ -900,8 +905,8 @@ namespace {
900905
moves_loop: // When in check, search starts from here
901906

902907
const PieceToHistory* contHist[] = { (ss-1)->continuationHistory, (ss-2)->continuationHistory,
903-
nullptr, (ss-4)->continuationHistory,
904-
nullptr, (ss-6)->continuationHistory };
908+
nullptr , (ss-4)->continuationHistory,
909+
nullptr , (ss-6)->continuationHistory };
905910

906911
Move countermove = thisThread->counterMoves[pos.piece_on(prevSq)][prevSq];
907912

@@ -911,7 +916,7 @@ namespace {
911916
countermove,
912917
ss->killers);
913918

914-
value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
919+
value = bestValue;
915920
moveCountPruning = false;
916921
ttCapture = ttMove && pos.capture_or_promotion(ttMove);
917922

@@ -1068,7 +1073,10 @@ namespace {
10681073

10691074
// Update the current move (this must be done after singular extension search)
10701075
ss->currentMove = move;
1071-
ss->continuationHistory = &thisThread->continuationHistory[inCheck][priorCapture][movedPiece][to_sq(move)];
1076+
ss->continuationHistory = &thisThread->continuationHistory[inCheck]
1077+
[captureOrPromotion]
1078+
[movedPiece]
1079+
[to_sq(move)];
10721080

10731081
// Step 15. Make the move
10741082
pos.do_move(move, st, givesCheck);
@@ -1323,7 +1331,7 @@ namespace {
13231331
Move ttMove, move, bestMove;
13241332
Depth ttDepth;
13251333
Value bestValue, value, ttValue, futilityValue, futilityBase, oldAlpha;
1326-
bool ttHit, pvHit, inCheck, givesCheck, evasionPrunable, priorCapture;
1334+
bool ttHit, pvHit, inCheck, givesCheck, captureOrPromotion, evasionPrunable;
13271335
int moveCount;
13281336

13291337
if (PvNode)
@@ -1337,7 +1345,6 @@ namespace {
13371345
(ss+1)->ply = ss->ply + 1;
13381346
bestMove = MOVE_NONE;
13391347
inCheck = pos.checkers();
1340-
priorCapture = pos.captured_piece();
13411348
moveCount = 0;
13421349

13431350
// Check for an immediate draw or maximum ply reached
@@ -1408,8 +1415,8 @@ namespace {
14081415
}
14091416

14101417
const PieceToHistory* contHist[] = { (ss-1)->continuationHistory, (ss-2)->continuationHistory,
1411-
nullptr, (ss-4)->continuationHistory,
1412-
nullptr, (ss-6)->continuationHistory };
1418+
nullptr , (ss-4)->continuationHistory,
1419+
nullptr , (ss-6)->continuationHistory };
14131420

14141421
// Initialize a MovePicker object for the current position, and prepare
14151422
// to search the moves. Because the depth is <= 0 here, only captures,
@@ -1426,6 +1433,7 @@ namespace {
14261433
assert(is_ok(move));
14271434

14281435
givesCheck = pos.gives_check(move);
1436+
captureOrPromotion = pos.capture_or_promotion(move);
14291437

14301438
moveCount++;
14311439

@@ -1475,7 +1483,10 @@ namespace {
14751483
}
14761484

14771485
ss->currentMove = move;
1478-
ss->continuationHistory = &thisThread->continuationHistory[inCheck][priorCapture][pos.moved_piece(move)][to_sq(move)];
1486+
ss->continuationHistory = &thisThread->continuationHistory[inCheck]
1487+
[captureOrPromotion]
1488+
[pos.moved_piece(move)]
1489+
[to_sq(move)];
14791490

14801491
// Make and search the move
14811492
pos.do_move(move, st, givesCheck);

0 commit comments

Comments
 (0)