const int GrainSize = 4;
// Evaluation weights, initialized from UCI options
- enum { Mobility, PassedPawns, Space, KingDangerUs, KingDangerThem };
+ enum { Mobility, PawnStructure, PassedPawns, Space, KingDangerUs, KingDangerThem };
Score Weights[6];
typedef Value V;
//
// Values modified by Joona Kiiski
const Score WeightsInternal[] = {
- S(289, 344), 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(271, 0), S(307, 0)
};
// MobilityBonus[PieceType][attacked] contains mobility bonuses for middle and
template<Color Us, bool Trace>
Score evaluate_threats(const Position& pos, EvalInfo& ei);
- template<Color Us>
- int evaluate_space(const Position& pos, EvalInfo& ei);
-
template<Color Us, bool Trace>
Score evaluate_passed_pawns(const Position& pos, EvalInfo& ei);
+ template<Color Us>
+ int evaluate_space(const Position& pos, EvalInfo& ei);
+
Score evaluate_unstoppable_pawns(const Position& pos, EvalInfo& ei);
Value interpolate(const Score& v, Phase ph, ScaleFactor sf);
+ Score apply_weight(Score v, Score w);
Score weight_option(const std::string& mgOpt, const std::string& egOpt, Score internalWeight);
double to_cp(Value v);
void trace_add(int idx, Score term_w, Score term_b = SCORE_ZERO);
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[Mobility] = weight_option("Mobility (Midgame)", "Mobility (Endgame)", WeightsInternal[Mobility]);
+ 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]);
// Probe the pawn hash table
ei.pi = Pawns::probe(pos, th->pawnsTable);
- score += ei.pi->pawns_value();
+ score += apply_weight(ei.pi->pawns_value(), Weights[PawnStructure]);
// Initialize attack and king safety bitboards
init_eval_info<WHITE>(pos, ei);
return Value((result + GrainSize / 2) & ~(GrainSize - 1));
}
+ // apply_weight() weights score v by score w trying to prevent overflow
+ Score apply_weight(Score v, Score w) {
+ return make_score((int(mg_value(v)) * mg_value(w)) / 0x100,
+ (int(eg_value(v)) * eg_value(w)) / 0x100);
+ }
// weight_option() computes the value of an evaluation weight, by combining
// two UCI-configurable weights (midgame and endgame) with an internal weight.