X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=a945c5c7f2c29d34b18ac2ccd08ac3c6b97dcc9d;hp=29d71ea9e0cce28078ccf4a715521d85b3f6bbac;hb=40f5abba104b411ec5234e2c93b05bba8e6bd3c8;hpb=9e8bf82350002b826e40581100dbbcd1d65c796e diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 29d71ea9..a945c5c7 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -17,10 +17,10 @@ along with this program. If not, see . */ +#include #include #include #include -#include #include "bitcount.h" #include "evaluate.h" @@ -90,8 +90,8 @@ namespace { } // Evaluation weights, initialized from UCI options - enum { Mobility, PawnStructure, PassedPawns, Space, KingDangerUs, KingDangerThem }; - struct Weight { int mg, eg; } Weights[6]; + enum { Mobility, PawnStructure, PassedPawns, Space, KingSafety }; + struct Weight { int mg, eg; } Weights[5]; typedef Value V; #define S(mg, eg) make_score(mg, eg) @@ -103,7 +103,7 @@ namespace { // // Values modified by Joona Kiiski const Score WeightsInternal[] = { - S(289, 344), S(233, 201), S(221, 273), S(46, 0), S(271, 0), S(307, 0) + S(289, 344), S(233, 201), S(221, 273), S(46, 0), S(289, 0) }; // MobilityBonus[PieceType][attacked] contains bonuses for middle and end @@ -169,7 +169,6 @@ namespace { const Score RookSemiopenFile = make_score(19, 10); const Score BishopPawns = make_score( 8, 12); const Score MinorBehindPawn = make_score(16, 0); - const Score UndefendedMinor = make_score(25, 10); const Score TrappedRook = make_score(90, 0); const Score Unstoppable = make_score( 0, 20); @@ -203,9 +202,9 @@ namespace { const int BishopCheck = 2; const int KnightCheck = 3; - // KingDanger[Color][attackUnits] contains the actual king danger weighted - // scores, indexed by color and by a calculated integer number. - Score KingDanger[COLOR_NB][128]; + // KingDanger[attackUnits] contains the actual king danger weighted + // scores, indexed by a calculated integer number. + Score KingDanger[128]; // apply_weight() weighs score 'v' by weight 'w' trying to prevent overflow @@ -502,7 +501,7 @@ namespace { // Finally, extract the king danger score from the KingDanger[] // array and subtract the score from evaluation. - score -= KingDanger[Us == Search::RootColor][attackUnits]; + score -= KingDanger[attackUnits]; } if (Trace) @@ -520,16 +519,9 @@ namespace { const Color Them = (Us == WHITE ? BLACK : WHITE); - Bitboard b, undefendedMinors, weakEnemies; + Bitboard b, weakEnemies; Score score = SCORE_ZERO; - // Undefended minors get penalized even if they are not under attack - undefendedMinors = pos.pieces(Them, BISHOP, KNIGHT) - & ~ei.attackedBy[Them][ALL_PIECES]; - - if (undefendedMinors) - score += UndefendedMinor; - // Enemies not defended by a pawn and under our attack weakEnemies = pos.pieces(Them) & ~ei.attackedBy[Them][PAWN] @@ -787,12 +779,6 @@ namespace { sf = ScaleFactor(50 * sf / SCALE_FACTOR_NORMAL); } - // Stealmate detection - Color stm = pos.side_to_move(); - if ( (ei.attackedBy[stm][ALL_PIECES] == ei.attackedBy[stm][KING]) - && (!(ei.attackedBy[stm][KING] & ~ei.attackedBy[~stm][ALL_PIECES]))) - sf = SCALE_FACTOR_DRAW; - // Interpolate between a middlegame and a (scaled by 'sf') endgame score Value v = mg_value(score) * int(ei.mi->game_phase()) + eg_value(score) * int(PHASE_MIDGAME - ei.mi->game_phase()) * sf / SCALE_FACTOR_NORMAL; @@ -916,8 +902,7 @@ namespace Eval { Weights[PawnStructure] = weight_option("Pawn Structure (Midgame)", "Pawn Structure (Endgame)", WeightsInternal[PawnStructure]); Weights[PassedPawns] = weight_option("Passed Pawns (Midgame)", "Passed Pawns (Endgame)", WeightsInternal[PassedPawns]); Weights[Space] = weight_option("Space", "Space", WeightsInternal[Space]); - Weights[KingDangerUs] = weight_option("Cowardice", "Cowardice", WeightsInternal[KingDangerUs]); - Weights[KingDangerThem] = weight_option("Aggressiveness", "Aggressiveness", WeightsInternal[KingDangerThem]); + Weights[KingSafety] = weight_option("King Safety", "King Safety", WeightsInternal[KingSafety]); const double MaxSlope = 30; const double Peak = 1280; @@ -925,9 +910,7 @@ namespace Eval { for (int t = 0, i = 1; i < 100; ++i) { t = int(std::min(Peak, std::min(0.4 * i * i, t + MaxSlope))); - - KingDanger[1][i] = apply_weight(make_score(t, 0), Weights[KingDangerUs]); - KingDanger[0][i] = apply_weight(make_score(t, 0), Weights[KingDangerThem]); + KingDanger[i] = apply_weight(make_score(t, 0), Weights[KingSafety]); } }