]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Retire is_mate()
[stockfish] / src / position.cpp
index 98f49c756fe989cee80a1d553889e84dd476aa7c..88eb22eaa338d910b08647abbf4e95b0f3841de3 100644 (file)
@@ -79,7 +79,7 @@ namespace {
 CheckInfo::CheckInfo(const Position& pos) {
 
   Color them = flip(pos.side_to_move());
-  Square ksq = pos.king_square(them);
+  ksq = pos.king_square(them);
 
   pinned = pos.pinned_pieces();
   dcCandidates = pos.discovered_check_candidates();
@@ -361,8 +361,8 @@ Bitboard Position::hidden_checkers() const {
   Square ksq = king_square(FindPinned ? sideToMove : flip(sideToMove));
 
   // Pinners are sliders, that give check when candidate pinned is removed
-  pinners &=  (pieces(ROOK, QUEEN) & RookPseudoAttacks[ksq])
-            | (pieces(BISHOP, QUEEN) & BishopPseudoAttacks[ksq]);
+  pinners &=  (pieces(ROOK, QUEEN) & PseudoAttacks[ROOK][ksq])
+            | (pieces(BISHOP, QUEEN) & PseudoAttacks[BISHOP][ksq]);
 
   while (pinners)
   {
@@ -641,7 +641,7 @@ bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
 
   assert(is_ok(m));
   assert(ci.dcCandidates == discovered_check_candidates());
-  assert(color_of(piece_on(from_sq(m))) == side_to_move());
+  assert(color_of(piece_moved(m)) == side_to_move());
 
   Square from = from_sq(m);
   Square to = to_sq(m);
@@ -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<MV_LEGAL>(*this).size()))
       return true;
 
   // Draw by repetition?
@@ -1531,15 +1531,6 @@ template bool Position::is_draw<false>() 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