]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Terminate threads before to exit main()
[stockfish] / src / position.cpp
index 21022ae1b2c18dc7655eef0460d80cd3bdc054db..7709fdd22c201d3e55dc228d15d3c4c2b7839eee 100644 (file)
@@ -363,6 +363,8 @@ void Position::print(Move move) const {
 
   string brd = twoRows + twoRows + twoRows + twoRows + dottedLine;
 
+  sync_cout;
+
   if (move)
   {
       Position p(*this);
@@ -373,7 +375,7 @@ void Position::print(Move move) const {
       if (piece_on(sq) != NO_PIECE)
           brd[513 - 68*rank_of(sq) + 4*file_of(sq)] = PieceToChar[piece_on(sq)];
 
-  cout << brd << "\nFen is: " << to_fen() << "\nKey is: " << st->key << endl;
+  cout << brd << "\nFen is: " << to_fen() << "\nKey is: " << st->key << sync_endl;
 }
 
 
@@ -1271,12 +1273,11 @@ int Position::see(Move m) const {
       // Locate the least valuable attacker for the side to move. The loop
       // below looks like it is potentially infinite, but it isn't. We know
       // that the side to move still has at least one attacker left.
-      for (pt = PAWN; !(stmAttackers & pieces(pt)); pt++)
+      for (pt = PAWN; (b = stmAttackers & pieces(pt)) == 0; pt++)
           assert(pt < KING);
 
       // Remove the attacker we just found from the 'occupied' bitboard,
       // and scan for new X-ray attacks behind the attacker.
-      b = stmAttackers & pieces(pt);
       occ ^= (b & (~b + 1));
       attackers |=  (attacks_bb<ROOK>(to, occ)   & pieces(ROOK, QUEEN))
                   | (attacks_bb<BISHOP>(to, occ) & pieces(BISHOP, QUEEN));