]> git.sesse.net Git - stockfish/commitdiff
Retire Position::in_check()
authorMarco Costalba <mcostalba@gmail.com>
Tue, 25 Dec 2012 16:59:35 +0000 (17:59 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 25 Dec 2012 16:59:35 +0000 (17:59 +0100)
It is redundant with Position::checkers()

No functional change.

src/endgame.cpp
src/evaluate.cpp
src/movegen.cpp
src/movepick.cpp
src/position.cpp
src/position.h
src/search.cpp

index c0d317b779234f4ae5cca323c221ffb5be8c4c93..d60ce3967773d4a4811702a5c77a291527a56199 100644 (file)
@@ -133,7 +133,7 @@ Value Endgame<KXK>::operator()(const Position& pos) const {
 
   // Stalemate detection with lone king
   if (    pos.side_to_move() == weakerSide
-      && !pos.in_check()
+      && !pos.checkers()
       && !MoveList<LEGAL>(pos).size()) {
     return VALUE_DRAW;
   }
index 8d9d01a71a7eff742bed41cce7bdf28c4d3ed391..1f396f759dec73b90edd30aa1e406325cf4c725f 100644 (file)
@@ -361,7 +361,7 @@ namespace {
 template<bool Trace>
 Value do_evaluate(const Position& pos, Value& margin) {
 
-  assert(!pos.in_check());
+  assert(!pos.checkers());
 
   EvalInfo ei;
   Score score, mobilityWhite, mobilityBlack;
@@ -1014,7 +1014,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
 
             // Opponent king cannot block because path is defended and position
             // is not in check. So only friendly pieces can be blockers.
-            assert(!pos.in_check());
+            assert(!pos.checkers());
             assert((queeningPath & pos.pieces()) == (queeningPath & pos.pieces(c)));
 
             // Add moves needed to free the path from friendly pieces and retest condition
index be848cf1a6acb370e1ddf262b4f79762ba187f56..3848611ce9bb8b286f14f007bae58e9005bb572a 100644 (file)
@@ -44,7 +44,7 @@ namespace {
     Square kto = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
     Bitboard enemies = pos.pieces(~us);
 
-    assert(!pos.in_check());
+    assert(!pos.checkers());
 
     const int K = Chess960 ? kto > kfrom ? -1 : 1
                            : Side == KING_SIDE ? -1 : 1;
@@ -307,7 +307,7 @@ template<GenType Type>
 MoveStack* generate(const Position& pos, MoveStack* mlist) {
 
   assert(Type == CAPTURES || Type == QUIETS || Type == NON_EVASIONS);
-  assert(!pos.in_check());
+  assert(!pos.checkers());
 
   Color us = pos.side_to_move();
   Bitboard target;
@@ -335,7 +335,7 @@ template MoveStack* generate<NON_EVASIONS>(const Position&, MoveStack*);
 template<>
 MoveStack* generate<QUIET_CHECKS>(const Position& pos, MoveStack* mlist) {
 
-  assert(!pos.in_check());
+  assert(!pos.checkers());
 
   Color us = pos.side_to_move();
   CheckInfo ci(pos);
@@ -366,7 +366,7 @@ MoveStack* generate<QUIET_CHECKS>(const Position& pos, MoveStack* mlist) {
 template<>
 MoveStack* generate<EVASIONS>(const Position& pos, MoveStack* mlist) {
 
-  assert(pos.in_check());
+  assert(pos.checkers());
 
   Square from, checksq;
   int checkersCnt = 0;
@@ -432,7 +432,7 @@ MoveStack* generate<LEGAL>(const Position& pos, MoveStack* mlist) {
   Bitboard pinned = pos.pinned_pieces();
   Square ksq = pos.king_square(pos.side_to_move());
 
-  end = pos.in_check() ? generate<EVASIONS>(pos, mlist)
+  end = pos.checkers() ? generate<EVASIONS>(pos, mlist)
                        : generate<NON_EVASIONS>(pos, mlist);
   while (cur != end)
       if (   (pinned || from_sq(cur->move) == ksq || type_of(cur->move) == ENPASSANT)
index ba99df0d1262fd7edffe0f03d0f68240d47c03bc..794fbde9b83366eb33e074e7b0b7fa921a5e4625 100644 (file)
@@ -68,7 +68,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
   endBadCaptures = moves + MAX_MOVES - 1;
   ss = s;
 
-  if (p.in_check())
+  if (p.checkers())
       phase = EVASION;
 
   else
@@ -96,7 +96,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
 
   assert(d <= DEPTH_ZERO);
 
-  if (p.in_check())
+  if (p.checkers())
       phase = EVASION;
 
   else if (d > DEPTH_QS_NO_CHECKS)
@@ -126,7 +126,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
 MovePicker::MovePicker(const Position& p, Move ttm, const History& h, PieceType pt)
                        : pos(p), H(h), cur(moves), end(moves) {
 
-  assert(!pos.in_check());
+  assert(!pos.checkers());
 
   phase = PROBCUT;
 
index ef5fd97091cc4f0f478b41954090ba8e72a1799f..e69528ad0c628a2aca423d0d2575386dc75390db 100644 (file)
@@ -617,7 +617,7 @@ bool Position::is_pseudo_legal(const Move m) const {
   // Evasions generator already takes care to avoid some kind of illegal moves
   // and pl_move_is_legal() relies on this. So we have to take care that the
   // same kind of moves are filtered out here.
-  if (in_check())
+  if (checkers())
   {
       if (type_of(pc) != KING)
       {
@@ -1144,7 +1144,7 @@ void Position::do_castle_move(Move m) {
 template<bool Do>
 void Position::do_null_move(StateInfo& backupSt) {
 
-  assert(!in_check());
+  assert(!checkers());
 
   // Back up the information necessary to undo the null move to the supplied
   // StateInfo object. Note that differently from normal case here backupSt
@@ -1428,7 +1428,7 @@ bool Position::is_draw() const {
       && (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg))
       return true;
 
-  if (st->rule50 > 99 && (!in_check() || MoveList<LEGAL>(*this).size()))
+  if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
       return true;
 
   if (CheckRepetition)
index e575c3ef9a7127cec8e95d73f75ee0e12d112e12..7fb840b669df9b133c50e005b1b1c117f29c2828 100644 (file)
@@ -122,7 +122,6 @@ public:
   Square castle_rook_square(Color c, CastlingSide s) const;
 
   // Checking
-  bool in_check() const;
   Bitboard checkers() const;
   Bitboard discovered_check_candidates() const;
   Bitboard pinned_pieces() const;
@@ -330,10 +329,6 @@ inline Bitboard Position::checkers() const {
   return st->checkersBB;
 }
 
-inline bool Position::in_check() const {
-  return st->checkersBB != 0;
-}
-
 inline Bitboard Position::discovered_check_candidates() const {
   return hidden_checkers<false>();
 }
index f7d3a9fd20f0be04863b1447a1ad622cc91f0fa6..bfcb53c989c1df9bad45ca4b11ede6eaadbabb74 100644 (file)
@@ -188,7 +188,7 @@ void Search::think() {
   {
       RootMoves.push_back(MOVE_NONE);
       sync_cout << "info depth 0 score "
-                << score_to_uci(RootPos.in_check() ? -VALUE_MATE : VALUE_DRAW)
+                << score_to_uci(RootPos.checkers() ? -VALUE_MATE : VALUE_DRAW)
                 << sync_endl;
 
       goto finalize;
@@ -491,7 +491,7 @@ namespace {
     // Step 1. Initialize node
     Thread* thisThread = pos.this_thread();
     moveCount = playedMoveCount = 0;
-    inCheck = pos.in_check();
+    inCheck = pos.checkers();
 
     if (SpNode)
     {
@@ -1081,7 +1081,7 @@ split_point_start: // At split points actual search starts from here
     const bool PvNode = (NT == PV);
 
     assert(NT == PV || NT == NonPV);
-    assert(InCheck == pos.in_check());
+    assert(InCheck == !!pos.checkers());
     assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
     assert(PvNode || (alpha == beta - 1));
     assert(depth <= DEPTH_ZERO);