mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Tablebases root ranking
This patch corrects both MultiPV behaviour and "go searchmoves" behaviour for tablebases. We change the logic of table base probing at root positions from filtering to ranking. The ranking code is much more straightforward than the current filtering code (this is a simplification), and also more versatile. If the root is a TB position, each root move is probed and assigned a TB score and a TB rank. The TB score is the Value to be displayed to the user for that move (unless the search finds a mate score), while the TB rank determines which moves should appear higher in a multi-pv search. In game play, the engine will always pick a move with the highest rank. Ranks run from -1000 to +1000: 901 to 1000 : TB win 900 : normally a TB win, in rare cases this could be a draw 1 to 899 : cursed TB wins 0 : draw -1 to -899 : blessed TB losses -900 : normally a TB loss, in rare cases this could be a draw -901 to -1000 : TB loss Normally all winning moves get rank 1000 (to let the search pick the best among them). The exception is if there has been a first repetition. In that case, moves are ranked strictly by DTZ so that the engine will play a move that lowers DTZ (and therefore cannot repeat the position a second time). Losing moves get rank -1000 unless they have relatively high DTZ, meaning they have some drawing chances. Those get ranks towards -901 (when they cross -900 the draw is certain). Closes https://github.com/official-stockfish/Stockfish/pull/1467 No functional change (without tablebases).
This commit is contained in:
committed by
Stéphane Nicolet
parent
e9aeaad052
commit
108f0da4d7
@@ -1105,6 +1105,35 @@ bool Position::is_draw(int ply) const {
|
||||
}
|
||||
|
||||
|
||||
// Position::has_repeated() tests whether there has been at least one repetition
|
||||
// of positions since the last capture or pawn move.
|
||||
|
||||
bool Position::has_repeated() const {
|
||||
|
||||
StateInfo* stc = st;
|
||||
while (true)
|
||||
{
|
||||
int i = 4, e = std::min(stc->rule50, stc->pliesFromNull);
|
||||
|
||||
if (e < i)
|
||||
return false;
|
||||
|
||||
StateInfo* stp = st->previous->previous;
|
||||
|
||||
do {
|
||||
stp = stp->previous->previous;
|
||||
|
||||
if (stp->key == stc->key)
|
||||
return true;
|
||||
|
||||
i += 2;
|
||||
} while (i <= e);
|
||||
|
||||
stc = stc->previous;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Position::flip() flips position with the white and black sides reversed. This
|
||||
/// is only useful for debugging e.g. for finding evaluation symmetry bugs.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user