Skip to content

Commit

Permalink
More bonus for bestMoves on past PV nodes
Browse files Browse the repository at this point in the history
It looks like it is important to keep past PV (ttPv) nodes as close as possible to current PV nodes.
Credits to Mark Tenzer (31m059) & Stefan Geschwentner who first tried ideas on ttPv nodes.

STC:
https://tests.stockfishchess.org/tests/view/5e2ff5efab2d69d58394fd52
LLR: 2.95 (-2.94,2.94) {-1.00,3.00}
Total: 13302 W: 2647 L: 2507 D: 8148
Ptnml(0-2): 237, 1540, 2956, 1632, 260

LTC:
https://tests.stockfishchess.org/tests/view/5e2fff38ab2d69d58394fd55
LLR: 2.95 (-2.94,2.94) {0.00,2.00}
Total: 15797 W: 2137 L: 1960 D: 11700
Ptnml(0-2): 96, 1443, 4628, 1547, 130

closes #2529

bench: 5545845
  • Loading branch information
pb00068 authored and vondele committed Jan 28, 2020
1 parent d878bc8 commit 71e0b53
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace {
void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus);
void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus);
void update_all_stats(const Position& pos, Stack* ss, Move bestMove, Value bestValue, Value beta, Square prevSq,
Move* quietsSearched, int quietCount, Move* capturesSearched, int captureCount, Depth depth);
Move* quietsSearched, int quietCount, Move* capturesSearched, int captureCount, Depth depth, bool pastPV);

// perft() is our utility to verify move generation. All the leaf nodes up
// to the given depth are generated and counted, and the sum is returned.
Expand Down Expand Up @@ -713,7 +713,7 @@ namespace {
if (ttValue >= beta)
{
if (!pos.capture_or_promotion(ttMove))
update_quiet_stats(pos, ss, ttMove, stat_bonus(depth));
update_quiet_stats(pos, ss, ttMove, stat_bonus(depth + (!PvNode && ttPv)));

// Extra penalty for early quiet moves of the previous ply
if ((ss-1)->moveCount <= 2 && !priorCapture)
Expand All @@ -722,7 +722,7 @@ namespace {
// Penalty for a quiet ttMove that fails low
else if (!pos.capture_or_promotion(ttMove))
{
int penalty = -stat_bonus(depth);
int penalty = -stat_bonus(depth + (!PvNode && ttPv));
thisThread->mainHistory[us][from_to(ttMove)] << penalty;
update_continuation_histories(ss, pos.moved_piece(ttMove), to_sq(ttMove), penalty);
}
Expand Down Expand Up @@ -1326,7 +1326,7 @@ namespace {

else if (bestMove)
update_all_stats(pos, ss, bestMove, bestValue, beta, prevSq,
quietsSearched, quietCount, capturesSearched, captureCount, depth);
quietsSearched, quietCount, capturesSearched, captureCount, depth, (!PvNode && ttPv));

// Bonus for prior countermove that caused the fail low
else if ( (depth >= 3 || PvNode)
Expand Down Expand Up @@ -1602,7 +1602,7 @@ namespace {
// update_all_stats() updates stats at the end of search() when a bestMove is found

void update_all_stats(const Position& pos, Stack* ss, Move bestMove, Value bestValue, Value beta, Square prevSq,
Move* quietsSearched, int quietCount, Move* capturesSearched, int captureCount, Depth depth) {
Move* quietsSearched, int quietCount, Move* capturesSearched, int captureCount, Depth depth, bool pastPV) {

int bonus1, bonus2;
Color us = pos.side_to_move();
Expand All @@ -1612,8 +1612,8 @@ namespace {
PieceType captured = type_of(pos.piece_on(to_sq(bestMove)));

bonus1 = stat_bonus(depth + 1);
bonus2 = bestValue > beta + PawnValueMg ? bonus1 // larger bonus
: stat_bonus(depth); // smaller bonus
bonus2 = pastPV || bestValue > beta + PawnValueMg ? bonus1 // larger bonus
: stat_bonus(depth); // smaller bonus

if (!pos.capture_or_promotion(bestMove))
{
Expand Down

3 comments on commit 71e0b53

@amchess
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At line 716 and 725, !PvNode is always true, isnt?

@vondele
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct. I've added this to the list of small cleanups

@amchess
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Please sign in to comment.