Skip to content

Commit

Permalink
Display classic and NNUE evaluation in trace mode
Browse files Browse the repository at this point in the history
show both the classical and NNUE evaluation,
as well as the Final evaluation.

closes #3042

No functional change.
  • Loading branch information
MJZ1977 authored and vondele committed Aug 22, 2020
1 parent e64b957 commit cbcb05c
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions src/evaluate.cpp
Expand Up @@ -972,42 +972,47 @@ std::string Eval::trace(const Position& pos) {

Value v;

std::memset(scores, 0, sizeof(scores));

pos.this_thread()->contempt = SCORE_ZERO; // Reset any dynamic contempt

v = Evaluation<TRACE>(pos).value();

ss << std::showpoint << std::noshowpos << std::fixed << std::setprecision(2)
<< " Term | White | Black | Total \n"
<< " | MG EG | MG EG | MG EG \n"
<< " ------------+-------------+-------------+------------\n"
<< " Material | " << Term(MATERIAL)
<< " Imbalance | " << Term(IMBALANCE)
<< " Pawns | " << Term(PAWN)
<< " Knights | " << Term(KNIGHT)
<< " Bishops | " << Term(BISHOP)
<< " Rooks | " << Term(ROOK)
<< " Queens | " << Term(QUEEN)
<< " Mobility | " << Term(MOBILITY)
<< " King safety | " << Term(KING)
<< " Threats | " << Term(THREAT)
<< " Passed | " << Term(PASSED)
<< " Space | " << Term(SPACE)
<< " Winnable | " << Term(WINNABLE)
<< " ------------+-------------+-------------+------------\n"
<< " Total | " << Term(TOTAL);

v = pos.side_to_move() == WHITE ? v : -v;

ss << "\nClassical evaluation: " << to_cp(v) << " (white side)\n";

if (Eval::useNNUE)
{
v = NNUE::evaluate(pos);
}
else
{
std::memset(scores, 0, sizeof(scores));

pos.this_thread()->contempt = SCORE_ZERO; // Reset any dynamic contempt

v = Evaluation<TRACE>(pos).value();

ss << std::showpoint << std::noshowpos << std::fixed << std::setprecision(2)
<< " Term | White | Black | Total \n"
<< " | MG EG | MG EG | MG EG \n"
<< " ------------+-------------+-------------+------------\n"
<< " Material | " << Term(MATERIAL)
<< " Imbalance | " << Term(IMBALANCE)
<< " Pawns | " << Term(PAWN)
<< " Knights | " << Term(KNIGHT)
<< " Bishops | " << Term(BISHOP)
<< " Rooks | " << Term(ROOK)
<< " Queens | " << Term(QUEEN)
<< " Mobility | " << Term(MOBILITY)
<< " King safety | " << Term(KING)
<< " Threats | " << Term(THREAT)
<< " Passed | " << Term(PASSED)
<< " Space | " << Term(SPACE)
<< " Winnable | " << Term(WINNABLE)
<< " ------------+-------------+-------------+------------\n"
<< " Total | " << Term(TOTAL);
v = pos.side_to_move() == WHITE ? v : -v;
ss << "\nNNUE evaluation: " << to_cp(v) << " (white side)\n";
}

v = evaluate(pos);
v = pos.side_to_move() == WHITE ? v : -v;
ss << "\nFinal evaluation: " << to_cp(v) << " (white side)\n";

ss << "\nFinal evaluation: " << to_cp(v) << " (white side)\n";

return ss.str();
}

0 comments on commit cbcb05c

Please sign in to comment.