X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=64b1bf4cf750d8d0902ce6f9d22c189eb175480b;hp=a945c5c7f2c29d34b18ac2ccd08ac3c6b97dcc9d;hb=ad937d0b2d2a9450686b9f3412c891a68ff19310;hpb=495a0fa699fb3f8ed36fe343fbd910479df4e2f1 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index a945c5c7..64b1bf4c 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -90,8 +90,8 @@ namespace { } // Evaluation weights, initialized from UCI options - enum { Mobility, PawnStructure, PassedPawns, Space, KingSafety }; - struct Weight { int mg, eg; } Weights[5]; + enum { Mobility, PawnStructure, PassedPawns, Space, KingDangerUs, KingDangerThem }; + struct Weight { int mg, eg; } Weights[6]; 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(289, 0) + S(289, 344), S(233, 201), S(221, 273), S(46, 0), S(271, 0), S(307, 0) }; // MobilityBonus[PieceType][attacked] contains bonuses for middle and end @@ -202,9 +202,9 @@ namespace { const int BishopCheck = 2; const int KnightCheck = 3; - // KingDanger[attackUnits] contains the actual king danger weighted - // scores, indexed by a calculated integer number. - Score KingDanger[128]; + // KingDanger[Color][attackUnits] contains the actual king danger weighted + // scores, indexed by color and by a calculated integer number. + Score KingDanger[COLOR_NB][128]; // apply_weight() weighs score 'v' by weight 'w' trying to prevent overflow @@ -501,7 +501,7 @@ namespace { // Finally, extract the king danger score from the KingDanger[] // array and subtract the score from evaluation. - score -= KingDanger[attackUnits]; + score -= KingDanger[Us == Search::RootColor][attackUnits]; } if (Trace) @@ -902,7 +902,8 @@ 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[KingSafety] = weight_option("King Safety", "King Safety", WeightsInternal[KingSafety]); + Weights[KingDangerUs] = weight_option("Cowardice", "Cowardice", WeightsInternal[KingDangerUs]); + Weights[KingDangerThem] = weight_option("Aggressiveness", "Aggressiveness", WeightsInternal[KingDangerThem]); const double MaxSlope = 30; const double Peak = 1280; @@ -910,7 +911,9 @@ 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[i] = apply_weight(make_score(t, 0), Weights[KingSafety]); + + KingDanger[1][i] = apply_weight(make_score(t, 0), Weights[KingDangerUs]); + KingDanger[0][i] = apply_weight(make_score(t, 0), Weights[KingDangerThem]); } }