X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=3e72c0e9c88c1185f6eb1a03e44fa60cd2a1a160;hp=cdbd9f0d1963ff13486c986c401e340e1c960d03;hb=2acc89c6e86cbf3b0bd42b4db2c66a925501bb0a;hpb=d7ef09727acc11c91b4a25b775c7f6d0bf1d37d8 diff --git a/src/position.cpp b/src/position.cpp index cdbd9f0d..3e72c0e9 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -867,8 +867,6 @@ void Position::do_capture_move(PieceType capture, Color them, Square to) { st->mgValue -= pst(them, capture, to); st->egValue -= pst(them, capture, to); - assert(!move_promotion(m) || capture != PAWN); - // Update material if (capture != PAWN) npMaterial[them] -= piece_value_midgame(capture); @@ -1869,21 +1867,6 @@ Value Position::compute_non_pawn_material(Color c) const { } -/// Position::is_mate() returns true or false depending on whether the -/// side to move is checkmated. Note that this function is currently very -/// slow, and shouldn't be used frequently inside the search. - -bool Position::is_mate() const { - - if (is_check()) - { - MovePicker mp = MovePicker(*this, false, MOVE_NONE, EmptySearchStack, Depth(0)); - return mp.get_next_move() == MOVE_NONE; - } - return false; -} - - /// 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. @@ -1908,6 +1891,17 @@ bool Position::is_draw() const { } +/// Position::is_mate() returns true or false depending on whether the +/// side to move is checkmated. + +bool Position::is_mate() const { + + MoveStack moves[256]; + + return is_check() && !generate_evasions(*this, moves, pinned_pieces(sideToMove)); +} + + /// Position::has_mate_threat() tests whether a given color has a mate in one /// from the current position. This function is quite slow, but it doesn't /// matter, because it is currently only called from PV nodes, which are rare.