From ec83e8a72c702713d550fb2a228f56a6c03704c4 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 27 Nov 2016 09:11:56 +0100 Subject: [PATCH 1/1] Fix regression: print const position Fix a regression introduced with new TB code. No functional change. --- src/position.cpp | 9 ++++++--- src/position.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 7c5ffdc5..1b82b6c0 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -86,7 +86,7 @@ PieceType min_attacker(const Bitboard*, Square, Bitboard, Bitboard&, Bitbo /// operator<<(Position) returns an ASCII representation of the position -std::ostream& operator<<(std::ostream& os, Position& pos) { +std::ostream& operator<<(std::ostream& os, const Position& pos) { os << "\n +---+---+---+---+---+---+---+---+\n"; @@ -108,9 +108,12 @@ std::ostream& operator<<(std::ostream& os, Position& pos) { if ( int(Tablebases::MaxCardinality) >= popcount(pos.pieces()) && !pos.can_castle(ANY_CASTLING)) { + StateInfo st; + Position p; + p.set(pos.fen(), pos.is_chess960(), &st, pos.this_thread()); Tablebases::ProbeState s1, s2; - Tablebases::WDLScore wdl = Tablebases::probe_wdl(pos, &s1); - int dtz = Tablebases::probe_dtz(pos, &s2); + Tablebases::WDLScore wdl = Tablebases::probe_wdl(p, &s1); + int dtz = Tablebases::probe_dtz(p, &s2); os << "\nTablebases WDL: " << std::setw(4) << wdl << " (" << s1 << ")" << "\nTablebases DTZ: " << std::setw(4) << dtz << " (" << s2 << ")"; } diff --git a/src/position.h b/src/position.h index 98928277..69bf40b1 100644 --- a/src/position.h +++ b/src/position.h @@ -190,7 +190,7 @@ private: bool chess960; }; -extern std::ostream& operator<<(std::ostream& os, Position& pos); +extern std::ostream& operator<<(std::ostream& os, const Position& pos); inline Color Position::side_to_move() const { return sideToMove; -- 2.39.2