]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Convert pawns evaluation to Score
[stockfish] / src / evaluate.cpp
index 21bd97b09e264243745f060f10fe9c67b58b0122..95cdaf3b266598caebf698f4093b70947843d2da 100644 (file)
@@ -64,8 +64,7 @@ namespace {
   const Score WeightKingOppSafetyInternal = make_score(259,   0);
 
   // Mobility and outposts bonus modified by Joona Kiiski
-  //
-  // Visually better to define tables constants
+
   typedef Value V;
   #define S(mg, eg) make_score(mg, eg)
 
@@ -330,7 +329,7 @@ Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
 
   // Probe the pawn hash table
   ei.pi = PawnTable[threadID]->get_pawn_info(pos);
-  ei.value += apply_weight(ei.pi->value(), WeightPawnStructure);
+  ei.value += apply_weight(ei.pi->pawns_value(), WeightPawnStructure);
 
   // Initialize king attack bitboards and king attack zones for both sides
   ei.attackedBy[WHITE][KING] = pos.attacks_from<KING>(pos.king_square(WHITE));
@@ -370,7 +369,7 @@ Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
   if (ei.pi->passed_pawns())
       evaluate_passed_pawns(pos, ei);
 
-  Phase phase = pos.game_phase();
+  Phase phase = ei.mi->game_phase();
 
   // Middle-game specific evaluation terms
   if (phase > PHASE_ENDGAME)
@@ -444,13 +443,10 @@ Value quick_evaluate(const Position &pos) {
 
   assert(pos.is_ok());
 
-  static const
-  ScaleFactor sf[2] = {SCALE_FACTOR_NORMAL, SCALE_FACTOR_NORMAL};
-
-  Phase ph = pos.game_phase();
-  Color stm = pos.side_to_move();
+  static const ScaleFactor sf[2] = {SCALE_FACTOR_NORMAL, SCALE_FACTOR_NORMAL};
 
-  return Sign[stm] * scale_by_game_phase(pos.value(), ph, sf);
+  Value v = scale_by_game_phase(pos.value(), MaterialInfoTable::game_phase(pos), sf);
+  return (pos.side_to_move() == WHITE ? v : -v);
 }