mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 09:06:45 +08:00
Start searching for a repetition from the 4th ply behind
A position can never repeat the one on the previous move. Thus we can start searching for a repetition from the 4th ply behind. In the case: std::min(st->rule50, st->pliesFromNull) < 4 We don't need to do any more calculations. This case happens very often - in more than a half of all calls of the function. No functional change.
This commit is contained in:
committed by
Marco Costalba
parent
76d113f5f0
commit
797602938d
@@ -1079,14 +1079,20 @@ bool Position::is_draw() const {
|
|||||||
if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
|
if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
StateInfo* stp = st;
|
int e = std::min(st->rule50, st->pliesFromNull);
|
||||||
for (int i = 2, e = std::min(st->rule50, st->pliesFromNull); i <= e; i += 2)
|
|
||||||
{
|
if (e < 4)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
StateInfo* stp = st->previous->previous;
|
||||||
|
|
||||||
|
do {
|
||||||
stp = stp->previous->previous;
|
stp = stp->previous->previous;
|
||||||
|
|
||||||
if (stp->key == st->key)
|
if (stp->key == st->key)
|
||||||
return true; // Draw at first repetition
|
return true; // Draw at first repetition
|
||||||
}
|
|
||||||
|
} while ((e -= 2) >= 4);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user