]> git.sesse.net Git - stockfish/commitdiff
Rename Bitboards print to pretty
authorMarco Costalba <mcostalba@gmail.com>
Sat, 30 Nov 2013 10:25:05 +0000 (11:25 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 30 Nov 2013 10:32:49 +0000 (11:32 +0100)
To align to same named Position function and
avoid using std::cout directly.

Also remove some stale <iostream> include while
there.

No functional change.

src/bitboard.cpp
src/bitboard.h
src/book.cpp
src/position.cpp

index a6502330ab7b23105c4ba917f5e502f91a712d68..84405411555430c30eb091f5a6243d611fb1a65a 100644 (file)
 
 #include <algorithm>
 #include <cstring>
-#include <iostream>
+#include <sstream>
 
 #include "bitboard.h"
 #include "bitcount.h"
-#include "misc.h"
 #include "rkiss.h"
 
 CACHE_LINE_ALIGNMENT
@@ -126,23 +125,24 @@ Square msb(Bitboard b) {
 #endif // ifndef USE_BSFQ
 
 
-/// Bitboards::print() prints a bitboard in an easily readable format to the
-/// standard output. This is sometimes useful for debugging.
+/// Bitboards::pretty() returns an ASCII representation of a bitboard to be
+/// printed to standard output. This is sometimes useful for debugging.
 
-void Bitboards::print(Bitboard b) {
+const std::string Bitboards::pretty(Bitboard b) {
 
-  sync_cout;
+  std::ostringstream ss;
 
   for (Rank rank = RANK_8; rank >= RANK_1; --rank)
   {
-      std::cout << "+---+---+---+---+---+---+---+---+" << '\n';
+      ss << "+---+---+---+---+---+---+---+---+" << '\n';
 
       for (File file = FILE_A; file <= FILE_H; ++file)
-          std::cout << "| " << (b & (file | rank) ? "X " : "  ");
+          ss << "| " << (b & (file | rank) ? "X " : "  ");
 
-      std::cout << "|\n";
+      ss << "|\n";
   }
-  std::cout << "+---+---+---+---+---+---+---+---+" << sync_endl;
+  ss << "+---+---+---+---+---+---+---+---+";
+  return ss.str();
 }
 
 
index 349005787fd402d6ab958818f46e1262fc4b8356..ecff5c3abd84a7ff5b6365ebf5329b4fcb09cef7 100644 (file)
@@ -26,7 +26,7 @@
 namespace Bitboards {
 
 void init();
-void print(Bitboard b);
+const std::string pretty(Bitboard b);
 
 }
 
index ec0a0f83bddbb24ebfa024553868c11f96c2b01f..8d021ab262118d3a529b1eec2e52aea9690572b4 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <algorithm>
 #include <cassert>
-#include <iostream>
 
 #include "book.h"
 #include "misc.h"
index ca7c460047bdd16716584916bbe4bd3abfcfe804..d141b4881dc9a622b4218b79ef9c927cdb9628ae 100644 (file)
@@ -21,7 +21,6 @@
 #include <cassert>
 #include <cstring>
 #include <iomanip>
-#include <iostream>
 #include <sstream>
 
 #include "bitcount.h"
@@ -34,8 +33,6 @@
 #include "tt.h"
 
 using std::string;
-using std::cout;
-using std::endl;
 
 static const string PieceToChar(" PNBRQK  pnbrqk");