- {}, {},
- { S(-35,-30), S(-22,-20), S(-9,-10), S( 3, 0), S(15, 10), S(27, 20), // Knights
- S( 37, 28), S( 42, 31), S(44, 33) },
- { S(-22,-27), S( -8,-13), S( 6, 1), S(20, 15), S(34, 29), S(48, 43), // Bishops
- S( 60, 55), S( 68, 63), S(74, 68), S(77, 72), S(80, 75), S(82, 77),
- S( 84, 79), S( 86, 81) },
- { S(-17,-33), S(-11,-16), S(-5, 0), S( 1, 16), S( 7, 32), S(13, 48), // Rooks
- S( 18, 64), S( 22, 80), S(26, 96), S(29,109), S(31,115), S(33,119),
- S( 35,122), S( 36,123), S(37,124) },
- { S(-12,-20), S( -8,-13), S(-5, -7), S(-2, -1), S( 1, 5), S( 4, 11), // Queens
- S( 7, 17), S( 10, 23), S(13, 29), S(16, 34), S(18, 38), S(20, 40),
- S( 22, 41), S( 23, 41), S(24, 41), S(25, 41), S(25, 41), S(25, 41),
- S( 25, 41), S( 25, 41), S(25, 41), S(25, 41), S(25, 41), S(25, 41),
- S( 25, 41), S( 25, 41), S(25, 41), S(25, 41) }
+ {}, {},
+ { S(-35,-30), S(-22,-20), S(-9,-10), S( 3, 0), S(15, 10), S(27, 20), // Knights
+ S( 37, 28), S( 42, 31), S(44, 33) },
+ { S(-22,-27), S( -8,-13), S( 6, 1), S(20, 15), S(34, 29), S(48, 43), // Bishops
+ S( 60, 55), S( 68, 63), S(74, 68), S(77, 72), S(80, 75), S(82, 77),
+ S( 84, 79), S( 86, 81) },
+ { S(-17,-33), S(-11,-16), S(-5, 0), S( 1, 16), S( 7, 32), S(13, 48), // Rooks
+ S( 18, 64), S( 22, 80), S(26, 96), S(29,109), S(31,115), S(33,119),
+ S( 35,122), S( 36,123), S(37,124) },
+ { S(-12,-20), S( -8,-13), S(-5, -7), S(-2, -1), S( 1, 5), S( 4, 11), // Queens
+ S( 7, 17), S( 10, 23), S(13, 29), S(16, 34), S(18, 38), S(20, 40),
+ S( 22, 41), S( 23, 41), S(24, 41), S(25, 41), S(25, 41), S(25, 41),
+ S( 25, 41), S( 25, 41), S(25, 41), S(25, 41), S(25, 41), S(25, 41),
+ S( 25, 41), S( 25, 41), S(25, 41), S(25, 41) }
V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0), // Knights
V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0),
V(0), V(0), V(4), V(8), V(8), V(4), V(0), V(0),
V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0), // Knights
V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0),
V(0), V(0), V(4), V(8), V(8), V(4), V(0), V(0),
- // KingExposed[Square] contains penalties based on the position of the
- // defending king, indexed by king's square (from white's point of view).
- const int KingExposed[] = {
- 2, 0, 2, 5, 5, 2, 0, 2,
- 2, 2, 4, 8, 8, 4, 2, 2,
- 7, 10, 12, 12, 12, 12, 10, 7,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15
- };
+ const int UnsupportedPinnedPiece = 2;
- stream.str("");
- stream << std::showpoint << std::showpos << std::fixed << std::setprecision(2);
- std::memset(scores, 0, 2 * (TOTAL + 1) * sizeof(Score));
-
- do_evaluate<true>(pos);
-
- std::string totals = stream.str();
- stream.str("");
-
- stream << std::setw(21) << "Eval term " << "| White | Black | Total \n"
- << " | MG EG | MG EG | MG EG \n"
- << "---------------------+-------------+-------------+---------------\n";
-
- row("Material, PST, Tempo", PST);
- row("Material imbalance", IMBALANCE);
- row("Pawns", PAWN);
- row("Knights", KNIGHT);
- row("Bishops", BISHOP);
- row("Rooks", ROOK);
- row("Queens", QUEEN);
- row("Mobility", MOBILITY);
- row("King safety", KING);
- row("Threats", THREAT);
- row("Passed pawns", PASSED);
- row("Space", SPACE);
-
- stream << "---------------------+-------------+-------------+---------------\n";
- row("Total", TOTAL);
- stream << totals;
-
- return stream.str();
+ std::memset(terms, 0, sizeof(terms));
+
+ Value v = do_evaluate<true>(pos);
+ v = pos.side_to_move() == WHITE ? v : -v; // White's point of view
+
+ std::stringstream ss;
+ ss << std::showpoint << std::noshowpos << std::fixed << std::setprecision(2)
+ << " Eval term | White | Black | Total \n"
+ << " | MG EG | MG EG | MG EG \n"
+ << "---------------------+-------------+-------------+-------------\n";
+
+ format_row(ss, "Material, PST, Tempo", PST);
+ format_row(ss, "Material imbalance", IMBALANCE);
+ format_row(ss, "Pawns", PAWN);
+ format_row(ss, "Knights", KNIGHT);
+ format_row(ss, "Bishops", BISHOP);
+ format_row(ss, "Rooks", ROOK);
+ format_row(ss, "Queens", QUEEN);
+ format_row(ss, "Mobility", MOBILITY);
+ format_row(ss, "King safety", KING);
+ format_row(ss, "Threats", THREAT);
+ format_row(ss, "Passed pawns", PASSED);
+ format_row(ss, "Space", SPACE);
+
+ ss << "---------------------+-------------+-------------+-------------\n";
+ format_row(ss, "Total", TOTAL);
+
+ ss << "\nTotal Evaluation: " << to_cp(v) << " (white side)\n";
+
+ return ss.str();