]> git.sesse.net Git - stockfish/commitdiff
Move RootColor from Eval to Search
authorMarco Costalba <mcostalba@gmail.com>
Sun, 21 Oct 2012 07:12:02 +0000 (09:12 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 21 Oct 2012 07:12:02 +0000 (09:12 +0200)
No functional change.

src/evaluate.cpp
src/evaluate.h
src/material.h
src/search.cpp
src/search.h
src/types.h

index b5b51d2cdc6ddecd295b0d1474b683436bbe1a82..c7549ce29237d41f8586cf9dab8a03fccbdb435e 100644 (file)
@@ -267,8 +267,6 @@ namespace {
 
 namespace Eval {
 
 
 namespace Eval {
 
-  Color RootColor;
-
   /// evaluate() is the main evaluation function. It always computes two
   /// values, an endgame score and a middle game score, and interpolates
   /// between them based on the remaining material.
   /// evaluate() is the main evaluation function. It always computes two
   /// values, an endgame score and a middle game score, and interpolates
   /// between them based on the remaining material.
@@ -319,7 +317,7 @@ namespace Eval {
     Value margin;
     std::string totals;
 
     Value margin;
     std::string totals;
 
-    RootColor = pos.side_to_move();
+    Search::RootColor = pos.side_to_move();
 
     TraceStream.str("");
     TraceStream << std::showpoint << std::showpos << std::fixed << std::setprecision(2);
 
     TraceStream.str("");
     TraceStream << std::showpoint << std::showpos << std::fixed << std::setprecision(2);
@@ -853,8 +851,8 @@ Value do_evaluate(const Position& pos, Value& margin) {
         // value that will be used for pruning because this value can sometimes
         // be very big, and so capturing a single attacking piece can therefore
         // result in a score change far bigger than the value of the captured piece.
         // value that will be used for pruning because this value can sometimes
         // be very big, and so capturing a single attacking piece can therefore
         // result in a score change far bigger than the value of the captured piece.
-        score -= KingDangerTable[Us == Eval::RootColor][attackUnits];
-        margins[Us] += mg_value(KingDangerTable[Us == Eval::RootColor][attackUnits]);
+        score -= KingDangerTable[Us == Search::RootColor][attackUnits];
+        margins[Us] += mg_value(KingDangerTable[Us == Search::RootColor][attackUnits]);
     }
 
     if (Trace)
     }
 
     if (Trace)
index a0418b79d4760c84e07edd897b1ca183ea3ea1ff..a76d10d143f5d44d66900f91ac7dcd5dd68b2ba8 100644 (file)
@@ -26,8 +26,6 @@ class Position;
 
 namespace Eval {
 
 
 namespace Eval {
 
-extern Color RootColor;
-
 extern void init();
 extern Value evaluate(const Position& pos, Value& margin);
 extern std::string trace(const Position& pos);
 extern void init();
 extern Value evaluate(const Position& pos, Value& margin);
 extern std::string trace(const Position& pos);
index 75074f91bbe411199acd48a20e0e7b9c3d1bd8f6..ba6ad1ea301c386ca30f3d445a0b4a52cdc8539d 100644 (file)
 
 const int MaterialTableSize = 8192;
 
 
 const int MaterialTableSize = 8192;
 
-/// Game phase
-enum Phase {
-  PHASE_ENDGAME = 0,
-  PHASE_MIDGAME = 128
-};
-
-
 /// MaterialEntry is a class which contains various information about a
 /// material configuration. It contains a material balance evaluation,
 /// a function pointer to a special endgame evaluation function (which in
 /// MaterialEntry is a class which contains various information about a
 /// material configuration. It contains a material balance evaluation,
 /// a function pointer to a special endgame evaluation function (which in
index 09d272e56983361fe813032c0051adf011169aac..3f5be1a38efe7fb8f823fcf2bda610aa211f64b7 100644 (file)
@@ -42,6 +42,7 @@ namespace Search {
   LimitsType Limits;
   std::vector<RootMove> RootMoves;
   Position RootPosition;
   LimitsType Limits;
   std::vector<RootMove> RootMoves;
   Position RootPosition;
+  Color RootColor;
   Time::point SearchTime;
   StateStackPtr SetupStates;
 }
   Time::point SearchTime;
   StateStackPtr SetupStates;
 }
@@ -174,7 +175,7 @@ void Search::think() {
 
   Position& pos = RootPosition;
   Chess960 = pos.is_chess960();
 
   Position& pos = RootPosition;
   Chess960 = pos.is_chess960();
-  Eval::RootColor = pos.side_to_move();
+  RootColor = pos.side_to_move();
   TimeMgr.init(Limits, pos.startpos_ply_counter(), pos.side_to_move());
   TT.new_search();
   H.clear();
   TimeMgr.init(Limits, pos.startpos_ply_counter(), pos.side_to_move());
   TT.new_search();
   H.clear();
@@ -192,8 +193,8 @@ void Search::think() {
   {
       int cf = Options["Contempt Factor"] * PawnValueMg / 100;  // In centipawns
       cf = cf * MaterialTable::game_phase(pos) / PHASE_MIDGAME; // Scale down with phase
   {
       int cf = Options["Contempt Factor"] * PawnValueMg / 100;  // In centipawns
       cf = cf * MaterialTable::game_phase(pos) / PHASE_MIDGAME; // Scale down with phase
-      DrawValue[ Eval::RootColor] = VALUE_DRAW - Value(cf);
-      DrawValue[~Eval::RootColor] = VALUE_DRAW + Value(cf);
+      DrawValue[ RootColor] = VALUE_DRAW - Value(cf);
+      DrawValue[~RootColor] = VALUE_DRAW + Value(cf);
   }
   else
       DrawValue[WHITE] = DrawValue[BLACK] = VALUE_DRAW;
   }
   else
       DrawValue[WHITE] = DrawValue[BLACK] = VALUE_DRAW;
index 5f9b74d7e530e4b0df12bc6e851678b9bc845249..e4592e27cca2197512b60af3a11d10c3f4da894e 100644 (file)
@@ -99,6 +99,7 @@ extern volatile SignalsType Signals;
 extern LimitsType Limits;
 extern std::vector<RootMove> RootMoves;
 extern Position RootPosition;
 extern LimitsType Limits;
 extern std::vector<RootMove> RootMoves;
 extern Position RootPosition;
+extern Color RootColor;
 extern Time::point SearchTime;
 extern StateStackPtr SetupStates;
 
 extern Time::point SearchTime;
 extern StateStackPtr SetupStates;
 
index 0774557e000a421aa63a5958368f0fb04237960c..ac97f7f1b0a8990a8a10c54c05e4f53905a2b70c 100644 (file)
@@ -144,6 +144,11 @@ enum CastlingSide {
   QUEEN_SIDE
 };
 
   QUEEN_SIDE
 };
 
+enum Phase {
+  PHASE_ENDGAME = 0,
+  PHASE_MIDGAME = 128
+};
+
 enum ScaleFactor {
   SCALE_FACTOR_DRAW   = 0,
   SCALE_FACTOR_NORMAL = 64,
 enum ScaleFactor {
   SCALE_FACTOR_DRAW   = 0,
   SCALE_FACTOR_NORMAL = 64,