]> git.sesse.net Git - stockfish/commitdiff
Merge pull request #89 from official-stockfish/pull_no_pretty
authorMarco Costalba <mcostalba@gmail.com>
Sat, 1 Nov 2014 21:24:33 +0000 (22:24 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 1 Nov 2014 21:24:33 +0000 (22:24 +0100)
Prefer operator<<() to pretty()

No functional change.

1  2 
src/position.cpp

diff --combined src/position.cpp
index 918d50e505e0d1e9ab8cb4b5b15f11c6d38d81ec,d43554d18e20fd9ff14a52014ee2a5dbcf086dd6..13fcdf247d65ba6d62570d05c3f72b368ff1bb57
  
  using std::string;
  
 -static const string PieceToChar(" PNBRQK  pnbrqk");
 -
  CACHE_LINE_ALIGNMENT
  
  Value PieceValue[PHASE_NB][PIECE_NB] = {
  { VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg },
  { VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg } };
  
 -static Score psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
 -
  namespace Zobrist {
  
    Key psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
@@@ -53,9 -57,6 +53,9 @@@ Key Position::exclusion_key() const { r
  
  namespace {
  
 +const string PieceToChar(" PNBRQK  pnbrqk");
 +Score psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
 +
  // min_attacker() is a helper function used by see() to locate the least
  // valuable attacker for the side to move, remove the attacker we just found
  // from the bitboards and scan for new X-ray attacks behind it.
@@@ -107,6 -108,30 +107,30 @@@ CheckInfo::CheckInfo(const Position& po
  }
  
  
+ /// operator<<(Position) returns an ASCII representation of the position
+ std::ostream& operator<<(std::ostream& os, const Position& pos) {
+   os << "\n +---+---+---+---+---+---+---+---+\n";
+   for (Rank r = RANK_8; r >= RANK_1; --r)
+   {
+       for (File f = FILE_A; f <= FILE_H; ++f)
+           os << " | " << PieceToChar[pos.piece_on(make_square(f, r))];
+       os << " |\n +---+---+---+---+---+---+---+---+\n";
+   }
+   os << "\nFen: " << pos.fen() << "\nKey: " << std::hex << std::uppercase
+      << std::setfill('0') << std::setw(16) << pos.st->key << "\nCheckers: ";
+   for (Bitboard b = pos.checkers(); b; )
+       os << UCI::format_square(pop_lsb(&b)) << " ";
+   return os;
+ }
  /// Position::init() initializes at startup the various arrays used to compute
  /// hash keys and the piece square tables. The latter is a two-step operation:
  /// Firstly, the white halves of the tables are copied from PSQT[] tables.
@@@ -429,32 -454,6 +453,6 @@@ const string Position::fen() const 
  }
  
  
- /// Position::pretty() returns an ASCII representation of the position
- const string Position::pretty() const {
-   std::ostringstream ss;
-   ss << "\n +---+---+---+---+---+---+---+---+\n";
-   for (Rank r = RANK_8; r >= RANK_1; --r)
-   {
-       for (File f = FILE_A; f <= FILE_H; ++f)
-           ss << " | " << PieceToChar[piece_on(make_square(f, r))];
-       ss << " |\n +---+---+---+---+---+---+---+---+\n";
-   }
-   ss << "\nFen: " << fen() << "\nKey: " << std::hex << std::uppercase
-      << std::setfill('0') << std::setw(16) << st->key << "\nCheckers: ";
-   for (Bitboard b = checkers(); b; )
-       ss << UCI::format_square(pop_lsb(&b)) << " ";
-   return ss.str();
- }
  /// Position::game_phase() calculates the game phase interpolating total non-pawn
  /// material between endgame and midgame limits.