1
0
Fork 0
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:
Marco Costalba 2013-12-03 11:37:29 +01:00
parent 342fd6385b
commit 2408243cf4

View file

@ -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;
do {
stp = stp->previous->previous; stp = stp->previous->previous;
if (stp->key == st->key) if (stp->key == st->key)
return true; // Draw after first repetition return true; // Draw at first repetition
i += 2;
} while (i <= e);
} }
return false; return false;