X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=3481b03d7c77ad2a01622eb7abd1960ffab7ca4a;hp=85fac61e6bac504dd9cc6f5b59939ce88398a5cb;hb=3e4dfb49a747be902d25ae06783f98ba29fb5030;hpb=c89274d8fb25d1c647a13918ccbc568347cb24a4 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 85fac61e..3481b03d 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -75,8 +75,8 @@ namespace { const int GrainSize = 8; // Evaluation weights, initialized from UCI options - enum { Mobility, PassedPawns, Space }; - Score Weights[3]; + enum { Mobility, PassedPawns, Space, KingDangerUs, KingDangerThem }; + Score Weights[6]; typedef Value V; #define S(mg, eg) make_score(mg, eg) @@ -88,7 +88,7 @@ namespace { // // Values modified by Joona Kiiski const Score WeightsInternal[] = { - S(252, 344), S(216, 266), S(46, 0) + S(289, 344), S(221, 273), S(46, 0), S(271, 0), S(307, 0) }; // MobilityBonus[PieceType][attacked] contains mobility bonuses for middle and @@ -197,10 +197,6 @@ namespace { // the strength of the enemy attack are added up into an integer, which // is used as an index to KingDangerTable[]. // - // King safety evaluation is asymmetrical and different for us (root color) - // and for our opponent. These values are used to init KingDangerTable. - const int KingDangerWeights[] = { 259, 247 }; - // KingAttackWeights[PieceType] contains king attack weights by piece type const int KingAttackWeights[] = { 0, 0, 2, 2, 3, 5 }; @@ -287,16 +283,11 @@ namespace Eval { void init() { - Weights[Mobility] = weight_option("Mobility (Middle Game)", "Mobility (Endgame)", WeightsInternal[Mobility]); - Weights[PassedPawns] = weight_option("Passed Pawns (Middle Game)", "Passed Pawns (Endgame)", WeightsInternal[PassedPawns]); - Weights[Space] = weight_option("Space", "Space", WeightsInternal[Space]); - - int KingDanger[] = { KingDangerWeights[0], KingDangerWeights[1] }; - - // If running in analysis mode, make sure we use symmetrical king safety. - // We do so by replacing both KingDanger weights by their average. - if (Options["UCI_AnalyseMode"]) - KingDanger[0] = KingDanger[1] = (KingDanger[0] + KingDanger[1]) / 2; + Weights[Mobility] = weight_option("Mobility (Middle Game)", "Mobility (Endgame)", WeightsInternal[Mobility]); + Weights[PassedPawns] = weight_option("Passed Pawns (Middle Game)", "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]); const int MaxSlope = 30; const int Peak = 1280; @@ -305,8 +296,8 @@ namespace Eval { { t = std::min(Peak, std::min(int(0.4 * i * i), t + MaxSlope)); - KingDangerTable[0][i] = apply_weight(make_score(t, 0), make_score(KingDanger[0], 0)); - KingDangerTable[1][i] = apply_weight(make_score(t, 0), make_score(KingDanger[1], 0)); + KingDangerTable[1][i] = apply_weight(make_score(t, 0), Weights[KingDangerUs]); + KingDangerTable[0][i] = apply_weight(make_score(t, 0), Weights[KingDangerThem]); } } @@ -591,6 +582,10 @@ Value do_evaluate(const Position& pos, Value& margin) { && !more_than_one(BetweenBB[s][pos.king_square(Them)] & pos.pieces())) score += BishopPinBonus; + // Penalty for bishop with same coloured pawns + if (Piece == BISHOP) + score -= make_score(4, 4) * ei.pi->same_colored_pawn_count(s, Us); + // Bishop and knight outposts squares if ( (Piece == BISHOP || Piece == KNIGHT) && !(pos.pieces(Them, PAWN) & attack_span_mask(Us, s)))