]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Code style triviality
[stockfish] / src / evaluate.cpp
index 21bd97b09e264243745f060f10fe9c67b58b0122..71f6cf79afaa594af2e6245285816e7b44898d37 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)
 
@@ -111,7 +110,7 @@ namespace {
 
   // Pointers table to access mobility tables through piece type
   const Score* MobilityBonus[8] = { 0, 0, KnightMobilityBonus, BishopMobilityBonus,
-                                   RookMobilityBonus, QueenMobilityBonus, 0, 0 };
+                                    RookMobilityBonus, QueenMobilityBonus, 0, 0 };
 
   // Outpost bonuses for knights and bishops, indexed by square (from white's
   // point of view).
@@ -141,7 +140,7 @@ namespace {
 
   // ThreatBonus[][] contains bonus according to which piece type
   // attacks which one.
-  #define Z make_score(0, 0)
+  #define Z S(0, 0)
 
   const Score ThreatBonus[8][8] = {
       { Z, Z, Z, Z, Z, Z, Z, Z }, // not used
@@ -253,8 +252,8 @@ namespace {
   Value SafetyTable[100];
 
   // Pawn and material hash tables, indexed by the current thread id
-  PawnInfoTable* PawnTable[8] = {0, 0, 0, 0, 0, 0, 0, 0};
   MaterialInfoTable* MaterialTable[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+  PawnInfoTable* PawnTable[8] = {0, 0, 0, 0, 0, 0, 0, 0};
 
   // Sizes of pawn and material hash tables
   const int PawnTableSize = 16384;
@@ -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);
 }