mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-17 07:36:23 +08:00
Skip draw by repetition check in qsearch
Cut in half the time spent in pos.draw() that accounts for a whopping 1% of total time ! Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -1778,7 +1778,7 @@ Value Position::compute_non_pawn_material(Color c) const {
|
||||
/// Position::is_draw() tests whether the position is drawn by material,
|
||||
/// repetition, or the 50 moves rule. It does not detect stalemates, this
|
||||
/// must be done by the search.
|
||||
|
||||
template<bool SkipRepetition>
|
||||
bool Position::is_draw() const {
|
||||
|
||||
// Draw by material?
|
||||
@@ -1791,13 +1791,18 @@ bool Position::is_draw() const {
|
||||
return true;
|
||||
|
||||
// Draw by repetition?
|
||||
for (int i = 4, e = Min(Min(st->gamePly, st->rule50), st->pliesFromNull); i <= e; i += 2)
|
||||
if (history[st->gamePly - i] == st->key)
|
||||
return true;
|
||||
if (!SkipRepetition)
|
||||
for (int i = 4, e = Min(Min(st->gamePly, st->rule50), st->pliesFromNull); i <= e; i += 2)
|
||||
if (history[st->gamePly - i] == st->key)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Explicit template instantiations
|
||||
template bool Position::is_draw<false>() const;
|
||||
template bool Position::is_draw<true>() const;
|
||||
|
||||
|
||||
/// Position::is_mate() returns true or false depending on whether the
|
||||
/// side to move is checkmated.
|
||||
|
||||
Reference in New Issue
Block a user