X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=4745da0210a921112852c3a3cb69192200660481;hp=85128c4f99b1091f11bf9c04a6e7334699f8d01d;hb=c8773c720af6fd5c3a8f84550ee36e5eb89f929e;hpb=72b88e09e1e867d3878e8323d6e320241727f64d diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 85128c4f..4745da02 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -58,15 +58,17 @@ namespace { // weights read from UCI parameters. The purpose is to be able to change // the evaluation weights while keeping the default values of the UCI // parameters at 100, which looks prettier. - const int WeightMobilityMidgameInternal = 0x100; - const int WeightMobilityEndgameInternal = 0x100; - const int WeightPawnStructureMidgameInternal = 0x100; - const int WeightPawnStructureEndgameInternal = 0x100; - const int WeightPassedPawnsMidgameInternal = 0x100; - const int WeightPassedPawnsEndgameInternal = 0x100; - const int WeightKingSafetyInternal = 0x110; - const int WeightKingOppSafetyInternal = 0x110; - const int WeightSpaceInternal = 0x30; + // + // Values modified by Joona Kiiski + const int WeightMobilityMidgameInternal = 0x0FA; + const int WeightMobilityEndgameInternal = 0x10A; + const int WeightPawnStructureMidgameInternal = 0x0EC; + const int WeightPawnStructureEndgameInternal = 0x0CD; + const int WeightPassedPawnsMidgameInternal = 0x108; + const int WeightPassedPawnsEndgameInternal = 0x109; + const int WeightKingSafetyInternal = 0x0F7; + const int WeightKingOppSafetyInternal = 0x101; + const int WeightSpaceInternal = 0x02F; // Visually better to define tables constants typedef Value V; @@ -167,18 +169,19 @@ namespace { V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0) // 8 }; - // Bonus for unstoppable passed pawns: + // Bonus for unstoppable passed pawns const Value UnstoppablePawnValue = Value(0x500); - // Rooks and queens on the 7th rank: - const Value MidgameRookOn7thBonus = Value(50); - const Value EndgameRookOn7thBonus = Value(100); - const Value MidgameQueenOn7thBonus = Value(25); - const Value EndgameQueenOn7thBonus = Value(50); + // Rooks and queens on the 7th rank + const Value MidgameRookOn7thBonus = Value(47); + const Value EndgameRookOn7thBonus = Value(98); + const Value MidgameQueenOn7thBonus = Value(27); + const Value EndgameQueenOn7thBonus = Value(54); - // Rooks on open files: - const Value RookOpenFileBonus = Value(40); - const Value RookHalfOpenFileBonus = Value(20); + + // Rooks on open files + const Value RookOpenFileBonus = Value(43); + const Value RookHalfOpenFileBonus = Value(19); // Penalty for rooks trapped inside a friendly king which has lost the // right to castle: @@ -286,7 +289,6 @@ namespace { void evaluate_space(const Position &p, Color us, EvalInfo &ei); inline Value apply_weight(Value v, int w); - Value scale_by_game_phase(Value mv, Value ev, Phase ph, const ScaleFactor sf[]); int count_1s_8bit(Bitboard b); @@ -525,6 +527,22 @@ void read_weights(Color us) { } +/// scale_by_game_phase() interpolates between a middle game and an endgame +/// score, based on game phase. It also scales the return value by a +/// ScaleFactor array. + +Value scale_by_game_phase(Value mv, Value ev, Phase ph, const ScaleFactor sf[]) { + + assert(mv > -VALUE_INFINITE && mv < VALUE_INFINITE); + assert(ev > -VALUE_INFINITE && ev < VALUE_INFINITE); + assert(ph >= PHASE_ENDGAME && ph <= PHASE_MIDGAME); + + ev = apply_scale_factor(ev, sf[(ev > Value(0) ? WHITE : BLACK)]); + + Value result = Value(int((mv * ph + ev * (128 - ph)) / 128)); + return Value(int(result) & ~(GrainSize - 1)); +} + namespace { // evaluate_common() computes terms common to all pieces attack @@ -1141,23 +1159,6 @@ namespace { } - // scale_by_game_phase() interpolates between a middle game and an endgame - // score, based on game phase. It also scales the return value by a - // ScaleFactor array. - - Value scale_by_game_phase(Value mv, Value ev, Phase ph, const ScaleFactor sf[]) { - - assert(mv > -VALUE_INFINITE && mv < VALUE_INFINITE); - assert(ev > -VALUE_INFINITE && ev < VALUE_INFINITE); - assert(ph >= PHASE_ENDGAME && ph <= PHASE_MIDGAME); - - ev = apply_scale_factor(ev, sf[(ev > Value(0) ? WHITE : BLACK)]); - - Value result = Value(int((mv * ph + ev * (128 - ph)) / 128)); - return Value(int(result) & ~(GrainSize - 1)); - } - - // count_1s_8bit() counts the number of nonzero bits in the 8 least // significant bits of a Bitboard. This function is used by the king // shield evaluation.