]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Rework Thread hierarchy
[stockfish] / src / position.cpp
index 55f8bcff5cd960bbcb4234e72e4d4fd8900f9d10..5dc94a634d665b08e878931ac1b7bb38389da8fa 100644 (file)
@@ -392,16 +392,18 @@ const string Position::pretty(Move move) const {
 
   string brd = twoRows + twoRows + twoRows + twoRows + dottedLine;
 
+  for (Bitboard b = pieces(); b; )
+  {
+      Square s = pop_lsb(&b);
+      brd[513 - 68 * rank_of(s) + 4 * file_of(s)] = PieceToChar[piece_on(s)];
+  }
+
   std::ostringstream ss;
 
   if (move)
       ss << "\nMove: " << (sideToMove == BLACK ? ".." : "")
          << move_to_san(*const_cast<Position*>(this), move);
 
-  for (Square sq = SQ_A1; sq <= SQ_H8; sq++)
-      if (piece_on(sq) != NO_PIECE)
-          brd[513 - 68*rank_of(sq) + 4*file_of(sq)] = PieceToChar[piece_on(sq)];
-
   ss << brd << "\nFen: " << fen() << "\nKey: " << std::hex << std::uppercase
      << std::setfill('0') << std::setw(16) << st->key << "\nCheckers: ";
 
@@ -542,7 +544,7 @@ bool Position::is_pseudo_legal(const Move m) const {
       return false;
 
   // The destination square cannot be occupied by a friendly piece
-  if (piece_on(to) != NO_PIECE && color_of(piece_on(to)) == us)
+  if (pieces(us) & to)
       return false;
 
   // Handle the special case of a pawn move
@@ -652,7 +654,7 @@ bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
       return true;
 
   // Discovery check ?
-  if (ci.dcCandidates && (ci.dcCandidates & from))
+  if (unlikely(ci.dcCandidates) && (ci.dcCandidates & from))
   {
       // For pawn and king moves we need to verify also direction
       if (   (pt != PAWN && pt != KING)