]> git.sesse.net Git - stockfish/blobdiff - src/material.cpp
Introduce DEPTH_NONE and use it
[stockfish] / src / material.cpp
index fc2f4b7cf35e454687c4ec2ead6a7276ea0546bd..973d3684715fcabc8ba91cb66334f44a63039423 100644 (file)
@@ -72,7 +72,7 @@ namespace {
     const Color Them = (Us == WHITE ? BLACK : WHITE);
     return   pos.non_pawn_material(Them) == Value(0)
           && pos.piece_count(Them, PAWN) == 0
-          && pos.non_pawn_material(Us) >= RookValueMidgame;
+          && pos.non_pawn_material(Us)   >= RookValueMidgame;
   }
 
   template<Color Us> bool is_KBPsK(const Position& pos) {
@@ -167,7 +167,8 @@ Phase MaterialInfoTable::game_phase(const Position& pos) {
 
   if (npm >= MidgameLimit)
       return PHASE_MIDGAME;
-  else if (npm <= EndgameLimit)
+
+  if (npm <= EndgameLimit)
       return PHASE_ENDGAME;
 
   return Phase(((npm - EndgameLimit) * 128) / (MidgameLimit - EndgameLimit));
@@ -182,7 +183,7 @@ Phase MaterialInfoTable::game_phase(const Position& pos) {
 MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) {
 
   Key key = pos.get_material_key();
-  int index = key & (size - 1);
+  unsigned index = unsigned(key & (size - 1));
   MaterialInfo* mi = entries + index;
 
   // If mi->key matches the position's material hash key, it means that we
@@ -204,14 +205,15 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) {
   if ((mi->evaluationFunction = funcs->get<EF>(key)) != NULL)
       return mi;
 
-  else if (is_KXK<WHITE>(pos) || is_KXK<BLACK>(pos))
+  if (is_KXK<WHITE>(pos) || is_KXK<BLACK>(pos))
   {
       mi->evaluationFunction = is_KXK<WHITE>(pos) ? &EvaluateKXK[WHITE] : &EvaluateKXK[BLACK];
       return mi;
   }
-  else if (   pos.pieces(PAWN)  == EmptyBoardBB
-           && pos.pieces(ROOK)  == EmptyBoardBB
-           && pos.pieces(QUEEN) == EmptyBoardBB)
+
+  if (   pos.pieces(PAWN)  == EmptyBoardBB
+      && pos.pieces(ROOK)  == EmptyBoardBB
+      && pos.pieces(QUEEN) == EmptyBoardBB)
   {
       // Minor piece endgame with at least one minor piece per side and
       // no pawns. Note that the case KmmK is already handled by KXK.
@@ -229,10 +231,8 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) {
   // OK, we didn't find any special evaluation function for the current
   // material configuration. Is there a suitable scaling function?
   //
-  // The code below is rather messy, and it could easily get worse later,
-  // if we decide to add more special cases. We face problems when there
-  // are several conflicting applicable scaling functions and we need to
-  // decide which one to use.
+  // We face problems when there are several conflicting applicable
+  // scaling functions and we need to decide which one to use.
   SF* sf;
 
   if ((sf = funcs->get<SF>(key)) != NULL)
@@ -402,10 +402,10 @@ Key EndgameFunctions::buildKey(const string& keyCode) {
         if (keyCode[i] == 'K')
             upcase = !upcase;
 
-        s << char(upcase? toupper(keyCode[i]) : tolower(keyCode[i]));
+        s << char(upcase ? toupper(keyCode[i]) : tolower(keyCode[i]));
     }
     s << 8 - keyCode.length() << "/8/8/8/8/8/8/8 w -";
-    return Position(s.str()).get_material_key();
+    return Position(s.str(), 0).get_material_key();
 }
 
 const string EndgameFunctions::swapColors(const string& keyCode) {