]> git.sesse.net Git - stockfish/commitdiff
Retire is_mate()
authorMarco Costalba <mcostalba@gmail.com>
Tue, 10 Jan 2012 10:57:06 +0000 (11:57 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 10 Jan 2012 20:53:07 +0000 (21:53 +0100)
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/move.cpp
src/position.cpp
src/position.h

index 7b8c4fcc62634e8eb086f867c3c6d0ee4d2a9fbf..1bf9b6a18b6556d727882d05894c19bab830f9b2 100644 (file)
@@ -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<MV_LEGAL>(pos).size() ? "+" : "#";
+      pos.undo_move(m);
+  }
 
   return san;
 }
 
   return san;
 }
index 085b9a3b1312771512a0b8615678d27283e4c983..88eb22eaa338d910b08647abbf4e95b0f3841de3 100644 (file)
@@ -1499,7 +1499,7 @@ bool Position::is_draw() const {
       return true;
 
   // Draw by the 50 moves rule?
       return true;
 
   // Draw by the 50 moves rule?
-  if (st->rule50 > 99 && !is_mate())
+  if (st->rule50 > 99 && (!in_check() || MoveList<MV_LEGAL>(*this).size()))
       return true;
 
   // Draw by repetition?
       return true;
 
   // Draw by repetition?
@@ -1531,15 +1531,6 @@ template bool Position::is_draw<false>() const;
 template bool Position::is_draw<true>() const;
 
 
 template bool Position::is_draw<true>() 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<MV_LEGAL>(*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
 /// 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
index 634fbc0d42ab680ada6b6569a70adf8d0aec7c5f..8826fa201161cfd9182502d1148b2105a410f106 100644 (file)
@@ -185,14 +185,9 @@ public:
   Value non_pawn_material(Color c) const;
   Score pst_delta(Piece piece, Square from, Square to) const;
 
   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 SkipRepetition> bool is_draw() const;
   template<bool SkipRepetition> bool is_draw() const;
-
-  // Plies from start position to the beginning of search
   int startpos_ply_counter() const;
   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;
   bool opposite_colored_bishops() const;
   bool has_pawn_on_7th(Color c) const;
   bool is_chess960() const;