X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.cpp;h=fd3f8035f30251c18211e633b835fc8fb49fc410;hb=27f2ce8f6e8462bd9be4b201dd95fc2df17aafe6;hp=6885b135cafad835c691087a336ba9d66708228e;hpb=490f67a3f89449e243c3e85feb13679f388d9e22;p=stockfish diff --git a/src/position.cpp b/src/position.cpp index 6885b135..fd3f8035 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1149,9 +1149,9 @@ void Position::clear() { startState.epSquare = SQ_NONE; st = &startState; - for (int i = 0; i < 8; i++) + for (int i = 0; i < PIECE_TYPE_NB; i++) for (int j = 0; j < 16; j++) - pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE; + pieceList[WHITE][i][j] = pieceList[BLACK][i][j] = SQ_NONE; } @@ -1255,17 +1255,20 @@ Value Position::compute_non_pawn_material(Color c) const { } -/// Position::is_draw() tests whether the position is drawn by repetition -/// or the 50 moves rule. It does not detect stalemates, this must be done -/// by the search. - +/// 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. bool Position::is_draw() const { + // Draw by material? + if ( !pieces(PAWN) + && (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg)) + return true; + // Draw by the 50 moves rule? if (st->rule50 > 99 && (!checkers() || MoveList(*this).size())) return true; - // Draw by repetition? int i = 4, e = std::min(st->rule50, st->pliesFromNull); if (i <= e) @@ -1276,7 +1279,7 @@ bool Position::is_draw() const { stp = stp->previous->previous; if (stp->key == st->key) - return true; + return true; // Draw after first repetition i += 2;