]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Scale down complexity for almost unwinnable endgames
[stockfish] / src / evaluate.cpp
index cb1ad1f420060ef6d7fa1e0b076f1a04ac3388b3..73e2144cc2d248faaf1fad03e08e43f6f3cb5870 100644 (file)
@@ -725,12 +725,17 @@ namespace {
     bool pawnsOnBothFlanks =   (pos.pieces(PAWN) & QueenSide)
                             && (pos.pieces(PAWN) & KingSide);
 
+    bool almostUnwinnable =   !pe->passed_count()
+                           &&  outflanking < 0
+                           && !pawnsOnBothFlanks;
+
     // Compute the initiative bonus for the attacking side
     int complexity =   9 * pe->passed_count()
                     + 11 * pos.count<PAWN>()
                     +  9 * outflanking
                     + 18 * pawnsOnBothFlanks
                     + 49 * !pos.non_pawn_material()
+                    - 36 * almostUnwinnable
                     -103 ;
 
     // Now apply the bonus: note that we find the attacking side by extracting