mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Shrink Position::is_draw()
No functional change.
This commit is contained in:
parent
342fd6385b
commit
2408243cf4
1 changed files with 8 additions and 18 deletions
|
@ -1229,35 +1229,25 @@ Value Position::compute_non_pawn_material(Color c) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Position::is_draw() tests whether the position is drawn by material,
|
/// Position::is_draw() tests whether the position is drawn by material, 50 moves
|
||||||
/// repetition, or the 50 moves rule. It does not detect stalemates: this
|
/// rule or repetition. It does not detect stalemates.
|
||||||
/// must be done by the search.
|
|
||||||
bool Position::is_draw() const {
|
bool Position::is_draw() const {
|
||||||
|
|
||||||
// Draw by material?
|
|
||||||
if ( !pieces(PAWN)
|
if ( !pieces(PAWN)
|
||||||
&& (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg))
|
&& (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Draw by the 50 moves rule?
|
|
||||||
if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
|
if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int i = 4, e = std::min(st->rule50, st->pliesFromNull);
|
StateInfo* stp = st;
|
||||||
|
for (int i = 2, e = std::min(st->rule50, st->pliesFromNull); i <= e; i += 2)
|
||||||
if (i <= e)
|
|
||||||
{
|
{
|
||||||
StateInfo* stp = st->previous->previous;
|
stp = stp->previous->previous;
|
||||||
|
|
||||||
do {
|
if (stp->key == st->key)
|
||||||
stp = stp->previous->previous;
|
return true; // Draw at first repetition
|
||||||
|
|
||||||
if (stp->key == st->key)
|
|
||||||
return true; // Draw after first repetition
|
|
||||||
|
|
||||||
i += 2;
|
|
||||||
|
|
||||||
} while (i <= e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue