Prevent division by zero in extinction bonus
authorFabian Fichter <ianfab@users.noreply.github.com>
Thu, 5 Aug 2021 14:42:54 +0000 (16:42 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Thu, 5 Aug 2021 14:42:54 +0000 (16:42 +0200)
Fixes #340.

src/evaluate.cpp

index 0e0dd46..b59df81 100644 (file)
@@ -1230,7 +1230,7 @@ namespace {
             else if (pos.extinction_value() == VALUE_MATE)
             {
                 // Losing chess variant bonus
-                score += make_score(pos.non_pawn_material(Us), pos.non_pawn_material(Us)) / pos.count<ALL_PIECES>(Us);
+                score += make_score(pos.non_pawn_material(Us), pos.non_pawn_material(Us)) / std::max(pos.count<ALL_PIECES>(Us), 1);
             }
             else if (pos.count<PAWN>(Us) == pos.count<ALL_PIECES>(Us))
             {