Re-add "Pawn Structure" UCI option

And reshuffle the code to not special case
this parameter.

No functional change.
This commit is contained in:
Marco Costalba
2013-05-25 12:18:58 +02:00
parent eafb66e1aa
commit 7222f47350
5 changed files with 21 additions and 23 deletions

View File

@@ -75,7 +75,7 @@ namespace {
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;
@@ -88,7 +88,7 @@ namespace {
//
// 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
@@ -240,15 +240,16 @@ namespace {
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);
@@ -272,8 +273,9 @@ 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[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]);
@@ -374,7 +376,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
// 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);
@@ -1119,6 +1121,11 @@ Value do_evaluate(const Position& pos, Value& margin) {
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.