Limit has_game_cycle() to only upcoming repetition

use the original algorithm according to the paper
http://web.archive.org/web/20201107002606/https://marcelk.net/2013-04-06/paper/upcoming-rep-v2.pdf,
which detects accurately if a position has an upcoming repetition. The 'no
progress' part of has_game_cycle has been removed, the function has been
renamed to upcoming_repetition to reflect this.

As a result of this fix, to the best of our knowledge, all PVs for completed
iterations that yield a mate or decisive table base score now end in mate or
contain a TB position, respectively.

passed non-regression STC:
https://tests.stockfishchess.org/tests/view/6679fa1d0c2db3fa2dcecbf2
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 63584 W: 16666 L: 16472 D: 30446
Ptnml(0-2): 186, 7552, 16146, 7698, 210

Passed non-regression LTC:
https://tests.stockfishchess.org/tests/view/667ac965e439ed1c7a9ca042
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 464574 W: 117493 L: 117729 D: 229352
Ptnml(0-2): 311, 52468, 126974, 52214, 320

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

bench: 1209805
This commit is contained in:
Shahin M. Shahin
2024-06-25 01:57:35 +03:00
committed by Joost VandeVondele
parent 69ad4667fb
commit 6b7822119f
3 changed files with 15 additions and 17 deletions
+4 -6
View File
@@ -534,9 +534,8 @@ Value Search::Worker::search(
// Limit the depth if extensions made it too large
depth = std::min(depth, MAX_PLY - 1);
// Check if we have an upcoming move that draws by repetition, or
// if the opponent had an alternative move earlier to this position.
if (!rootNode && alpha < VALUE_DRAW && pos.has_game_cycle(ss->ply))
// Check if we have an upcoming move that draws by repetition.
if (!rootNode && alpha < VALUE_DRAW && pos.upcoming_repetition(ss->ply))
{
alpha = value_draw(this->nodes);
if (alpha >= beta)
@@ -1447,9 +1446,8 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
assert(PvNode || (alpha == beta - 1));
assert(depth <= 0);
// Check if we have an upcoming move that draws by repetition, or if
// the opponent had an alternative move earlier to this position. (~1 Elo)
if (alpha < VALUE_DRAW && pos.has_game_cycle(ss->ply))
// Check if we have an upcoming move that draws by repetition. (~1 Elo)
if (alpha < VALUE_DRAW && pos.upcoming_repetition(ss->ply))
{
alpha = value_draw(this->nodes);
if (alpha >= beta)