From 6b909b2343190f2989d21c8f69f40e9f09c530c0 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 21 Oct 2012 09:12:02 +0200 Subject: [PATCH 1/1] Move RootColor from Eval to Search No functional change. --- src/evaluate.cpp | 8 +++----- src/evaluate.h | 2 -- src/material.h | 7 ------- src/search.cpp | 7 ++++--- src/search.h | 1 + src/types.h | 5 +++++ 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index b5b51d2c..c7549ce2 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -267,8 +267,6 @@ namespace { 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. @@ -319,7 +317,7 @@ namespace Eval { 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); @@ -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. - 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) diff --git a/src/evaluate.h b/src/evaluate.h index a0418b79..a76d10d1 100644 --- a/src/evaluate.h +++ b/src/evaluate.h @@ -26,8 +26,6 @@ class Position; namespace Eval { -extern Color RootColor; - extern void init(); extern Value evaluate(const Position& pos, Value& margin); extern std::string trace(const Position& pos); diff --git a/src/material.h b/src/material.h index 75074f91..ba6ad1ea 100644 --- a/src/material.h +++ b/src/material.h @@ -27,13 +27,6 @@ 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 diff --git a/src/search.cpp b/src/search.cpp index 09d272e5..3f5be1a3 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -42,6 +42,7 @@ namespace Search { LimitsType Limits; std::vector RootMoves; Position RootPosition; + Color RootColor; Time::point SearchTime; StateStackPtr SetupStates; } @@ -174,7 +175,7 @@ void Search::think() { 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(); @@ -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 - 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; diff --git a/src/search.h b/src/search.h index 5f9b74d7..e4592e27 100644 --- a/src/search.h +++ b/src/search.h @@ -99,6 +99,7 @@ extern volatile SignalsType Signals; extern LimitsType Limits; extern std::vector RootMoves; extern Position RootPosition; +extern Color RootColor; extern Time::point SearchTime; extern StateStackPtr SetupStates; diff --git a/src/types.h b/src/types.h index 0774557e..ac97f7f1 100644 --- a/src/types.h +++ b/src/types.h @@ -144,6 +144,11 @@ enum CastlingSide { QUEEN_SIDE }; +enum Phase { + PHASE_ENDGAME = 0, + PHASE_MIDGAME = 128 +}; + enum ScaleFactor { SCALE_FACTOR_DRAW = 0, SCALE_FACTOR_NORMAL = 64, -- 2.39.2