From c19ea4b0005c312aceb82d31ea17c2e1ff0729d2 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Tue, 10 Jan 2012 11:57:06 +0100 Subject: [PATCH] Retire is_mate() No functional change. Signed-off-by: Marco Costalba --- src/move.cpp | 14 +++++++------- src/position.cpp | 11 +---------- src/position.h | 7 +------ 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/move.cpp b/src/move.cpp index 7b8c4fcc..1bf9b6a1 100644 --- a/src/move.cpp +++ b/src/move.cpp @@ -147,13 +147,13 @@ const string move_to_san(Position& pos, Move m) { } } - // The move gives check? We don't use pos.move_gives_check() here - // because we need to test for a mate after the move is done. - StateInfo st; - pos.do_move(m, st); - if (pos.in_check()) - san += pos.is_mate() ? "#" : "+"; - pos.undo_move(m); + if (pos.move_gives_check(m, CheckInfo(pos))) + { + StateInfo st; + pos.do_move(m, st); + san += MoveList(pos).size() ? "+" : "#"; + pos.undo_move(m); + } return san; } diff --git a/src/position.cpp b/src/position.cpp index 085b9a3b..88eb22ea 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1499,7 +1499,7 @@ bool Position::is_draw() const { return true; // Draw by the 50 moves rule? - if (st->rule50 > 99 && !is_mate()) + if (st->rule50 > 99 && (!in_check() || MoveList(*this).size())) return true; // Draw by repetition? @@ -1531,15 +1531,6 @@ template bool Position::is_draw() const; template 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 { - - return in_check() && !MoveList(*this).size(); -} - - /// Position::init() is a static member function which initializes at startup /// the various arrays used to compute hash keys and the piece square tables. /// The latter is a two-step operation: First, the white halves of the tables diff --git a/src/position.h b/src/position.h index 634fbc0d..8826fa20 100644 --- a/src/position.h +++ b/src/position.h @@ -185,14 +185,9 @@ public: Value non_pawn_material(Color c) const; Score pst_delta(Piece piece, Square from, Square to) const; - // Game termination checks - bool is_mate() const; + // Other properties of the position template bool is_draw() const; - - // Plies from start position to the beginning of search int startpos_ply_counter() const; - - // Other properties of the position bool opposite_colored_bishops() const; bool has_pawn_on_7th(Color c) const; bool is_chess960() const; -- 2.39.2