]> git.sesse.net Git - stockfish/commitdiff
Re-add "Pawn Structure" UCI option
authorMarco Costalba <mcostalba@gmail.com>
Sat, 25 May 2013 10:18:58 +0000 (12:18 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 25 May 2013 10:38:14 +0000 (12:38 +0200)
And reshuffle the code to not special case
this parameter.

No functional change.

polyglot.ini
src/evaluate.cpp
src/pawns.cpp
src/types.h
src/ucioption.cpp

index 86c8c7cafe9c7bca0313cc8e3ced93a420b7cadc..58ddb3c7265eaf4143ea508fad36c6a7e6f06439 100644 (file)
@@ -19,9 +19,9 @@ Search Log Filename = SearchLog.txt
 Book File = book.bin
 Best Book Move = false
 Contempt Factor = 0
-Mobility (Middle Game) = 100
+Mobility (Midgame) = 100
 Mobility (Endgame) = 100
-Passed Pawns (Middle Game) = 100
+Passed Pawns (Midgame) = 100
 Passed Pawns (Endgame) = 100
 Space = 100
 Aggressiveness = 100
index be76fe33a2fd3e3d194dec696d06e2bd9871f039..4b1862dbcef3f2c78a0b31ad660bfbf8cdbfffee 100644 (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.
index 5b64ac6163091814e53150544b2add49c93e10b0..3b04515f5f70889445bd2506449faac2ce599582 100644 (file)
@@ -62,8 +62,6 @@ namespace {
     S(34,68), S(83,166), S(0, 0), S( 0, 0)
   };
 
-  const Score PawnStructureWeight = S(233, 201);
-
   // Weakness of our pawn shelter in front of the king indexed by [king pawn][rank]
   const Value ShelterWeakness[2][RANK_NB] =
   { { V(141), V(0), V(38), V(102), V(128), V(141), V(141) },
@@ -215,9 +213,6 @@ Entry* probe(const Position& pos, Table& entries) {
 
   e->value =  evaluate_pawns<WHITE>(pos, wPawns, bPawns, e)
             - evaluate_pawns<BLACK>(pos, bPawns, wPawns, e);
-
-  e->value = apply_weight(e->value, PawnStructureWeight);
-
   return e;
 }
 
index 1e036e8997ce421437ef2632594d80b148043129..c21b55be4f4c992d9b23c5eff77c051b884f1318 100644 (file)
@@ -325,12 +325,6 @@ inline Score operator/(Score s, int i) {
   return make_score(mg_value(s) / i, eg_value(s) / i);
 }
 
-/// Weight score v by score w trying to prevent overflow
-inline 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);
-}
-
 #undef ENABLE_OPERATORS_ON
 #undef ENABLE_SAFE_OPERATORS_ON
 
index 4bb4369fc843b593759ef530e0bbb718a0f1def5..3afa59d3137ebf6afe8423491ed5fbe22d9c64d9 100644 (file)
@@ -65,9 +65,11 @@ void init(OptionsMap& o) {
   o["Book File"]                   = Option("book.bin");
   o["Best Book Move"]              = Option(false);
   o["Contempt Factor"]             = Option(0, -50,  50);
-  o["Mobility (Middle Game)"]      = Option(100, 0, 200, on_eval);
+  o["Mobility (Midgame)"]          = Option(100, 0, 200, on_eval);
   o["Mobility (Endgame)"]          = Option(100, 0, 200, on_eval);
-  o["Passed Pawns (Middle Game)"]  = Option(100, 0, 200, on_eval);
+  o["Pawn Structure (Midgame)"]    = Option(100, 0, 200, on_eval);
+  o["Pawn Structure (Endgame)"]    = Option(100, 0, 200, on_eval);
+  o["Passed Pawns (Midgame)"]      = Option(100, 0, 200, on_eval);
   o["Passed Pawns (Endgame)"]      = Option(100, 0, 200, on_eval);
   o["Space"]                       = Option(100, 0, 200, on_eval);
   o["Aggressiveness"]              = Option(100, 0, 200, on_eval);