1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Move RootColor from Eval to Search

No functional change.
This commit is contained in:
Marco Costalba 2012-10-21 09:12:02 +02:00
parent 55bd27b8f0
commit 6b909b2343
6 changed files with 13 additions and 17 deletions

View file

@ -267,8 +267,6 @@ namespace {
namespace Eval { namespace Eval {
Color RootColor;
/// evaluate() is the main evaluation function. It always computes two /// evaluate() is the main evaluation function. It always computes two
/// values, an endgame score and a middle game score, and interpolates /// values, an endgame score and a middle game score, and interpolates
/// between them based on the remaining material. /// between them based on the remaining material.
@ -319,7 +317,7 @@ namespace Eval {
Value margin; Value margin;
std::string totals; std::string totals;
RootColor = pos.side_to_move(); Search::RootColor = pos.side_to_move();
TraceStream.str(""); TraceStream.str("");
TraceStream << std::showpoint << std::showpos << std::fixed << std::setprecision(2); 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 // value that will be used for pruning because this value can sometimes
// be very big, and so capturing a single attacking piece can therefore // 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. // result in a score change far bigger than the value of the captured piece.
score -= KingDangerTable[Us == Eval::RootColor][attackUnits]; score -= KingDangerTable[Us == Search::RootColor][attackUnits];
margins[Us] += mg_value(KingDangerTable[Us == Eval::RootColor][attackUnits]); margins[Us] += mg_value(KingDangerTable[Us == Search::RootColor][attackUnits]);
} }
if (Trace) if (Trace)

View file

@ -26,8 +26,6 @@ class Position;
namespace Eval { namespace Eval {
extern Color RootColor;
extern void init(); extern void init();
extern Value evaluate(const Position& pos, Value& margin); extern Value evaluate(const Position& pos, Value& margin);
extern std::string trace(const Position& pos); extern std::string trace(const Position& pos);

View file

@ -27,13 +27,6 @@
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 /// MaterialEntry is a class which contains various information about a
/// material configuration. It contains a material balance evaluation, /// material configuration. It contains a material balance evaluation,
/// a function pointer to a special endgame evaluation function (which in /// a function pointer to a special endgame evaluation function (which in

View file

@ -42,6 +42,7 @@ namespace Search {
LimitsType Limits; LimitsType Limits;
std::vector<RootMove> RootMoves; std::vector<RootMove> RootMoves;
Position RootPosition; Position RootPosition;
Color RootColor;
Time::point SearchTime; Time::point SearchTime;
StateStackPtr SetupStates; StateStackPtr SetupStates;
} }
@ -174,7 +175,7 @@ void Search::think() {
Position& pos = RootPosition; Position& pos = RootPosition;
Chess960 = pos.is_chess960(); 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()); TimeMgr.init(Limits, pos.startpos_ply_counter(), pos.side_to_move());
TT.new_search(); TT.new_search();
H.clear(); H.clear();
@ -192,8 +193,8 @@ void Search::think() {
{ {
int cf = Options["Contempt Factor"] * PawnValueMg / 100; // In centipawns int cf = Options["Contempt Factor"] * PawnValueMg / 100; // In centipawns
cf = cf * MaterialTable::game_phase(pos) / PHASE_MIDGAME; // Scale down with phase cf = cf * MaterialTable::game_phase(pos) / PHASE_MIDGAME; // Scale down with phase
DrawValue[ Eval::RootColor] = VALUE_DRAW - Value(cf); DrawValue[ RootColor] = VALUE_DRAW - Value(cf);
DrawValue[~Eval::RootColor] = VALUE_DRAW + Value(cf); DrawValue[~RootColor] = VALUE_DRAW + Value(cf);
} }
else else
DrawValue[WHITE] = DrawValue[BLACK] = VALUE_DRAW; DrawValue[WHITE] = DrawValue[BLACK] = VALUE_DRAW;

View file

@ -99,6 +99,7 @@ extern volatile SignalsType Signals;
extern LimitsType Limits; extern LimitsType Limits;
extern std::vector<RootMove> RootMoves; extern std::vector<RootMove> RootMoves;
extern Position RootPosition; extern Position RootPosition;
extern Color RootColor;
extern Time::point SearchTime; extern Time::point SearchTime;
extern StateStackPtr SetupStates; extern StateStackPtr SetupStates;

View file

@ -144,6 +144,11 @@ enum CastlingSide {
QUEEN_SIDE QUEEN_SIDE
}; };
enum Phase {
PHASE_ENDGAME = 0,
PHASE_MIDGAME = 128
};
enum ScaleFactor { enum ScaleFactor {
SCALE_FACTOR_DRAW = 0, SCALE_FACTOR_DRAW = 0,
SCALE_FACTOR_NORMAL = 64, SCALE_FACTOR_NORMAL = 64,