X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=db4c857b0d25401cf97e3f70b56c8aeb10a46ee1;hp=e2a59e5df3b44eee261e530261a1134bd3ea738f;hb=880e3cd7c82c82776e85042c849e884811378e21;hpb=3b315c9adab141830a81afbdff70c18336763e51 diff --git a/src/position.cpp b/src/position.cpp index e2a59e5d..db4c857b 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -25,12 +25,12 @@ #include "bitcount.h" #include "movegen.h" -#include "notation.h" #include "position.h" #include "psqtab.h" #include "rkiss.h" #include "thread.h" #include "tt.h" +#include "notation.h" using std::string; @@ -430,17 +430,12 @@ const string Position::fen() const { } -/// Position::pretty() returns an ASCII representation of the position to be -/// printed to the standard output together with the move's san notation. +/// Position::pretty() returns an ASCII representation of the position -const string Position::pretty(Move m) const { +const string Position::pretty() const { std::ostringstream ss; - if (m) - ss << "\nMove: " << (sideToMove == BLACK ? ".." : "") - << move_to_san(*const_cast(this), m); - ss << "\n +---+---+---+---+---+---+---+---+\n"; for (Rank r = RANK_8; r >= RANK_1; --r) @@ -457,23 +452,20 @@ const string Position::pretty(Move m) const { for (Bitboard b = checkers(); b; ) ss << to_string(pop_lsb(&b)) << " "; - ss << "\nLegal moves: "; - for (MoveList it(*this); *it; ++it) - ss << move_to_san(*const_cast(this), *it) << " "; - return ss.str(); } -/// Position::game_phase() calculates the game phase of the position +/// Position::game_phase() calculates the game phase interpolating total non-pawn +/// material between endgame and midgame limits. Phase Position::game_phase() const { Value npm = st->npMaterial[WHITE] + st->npMaterial[BLACK]; - return npm >= MidgameLimit ? PHASE_MIDGAME - : npm <= EndgameLimit ? PHASE_ENDGAME - : Phase(((npm - EndgameLimit) * 128) / (MidgameLimit - EndgameLimit)); + npm = std::max(EndgameLimit, std::min(npm, MidgameLimit)); + + return Phase(((npm - EndgameLimit) * 128) / (MidgameLimit - EndgameLimit)); } @@ -1125,10 +1117,6 @@ Value Position::see(Move m) const { bool Position::is_draw() const { - if ( !pieces(PAWN) - && (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg)) - return true; - if (st->rule50 > 99 && (!checkers() || MoveList(*this).size())) return true;