X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=913be63f1702c21eb4d76277c2cc4a6daaeb3954;hp=1be384410b4d4a59091528826880a3f80f668b83;hb=94b9c65e09b5d396bebb29b62d9979139b5fbdfa;hpb=9b1d5bd5343540db412c50ae2944246e3f25d18b diff --git a/src/endgame.cpp b/src/endgame.cpp index 1be38441..913be63f 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -115,8 +115,8 @@ void init_bitbases() { template<> Value EvaluationFunction::apply(const Position& pos) const { - assert(pos.non_pawn_material(weakerSide) == Value(0)); - assert(pos.piece_count(weakerSide, PAWN) == Value(0)); + assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO); + assert(pos.piece_count(weakerSide, PAWN) == VALUE_ZERO); Square winnerKSq = pos.king_square(strongerSide); Square loserKSq = pos.king_square(weakerSide); @@ -141,8 +141,8 @@ Value EvaluationFunction::apply(const Position& pos) const { template<> Value EvaluationFunction::apply(const Position& pos) const { - assert(pos.non_pawn_material(weakerSide) == Value(0)); - assert(pos.piece_count(weakerSide, PAWN) == Value(0)); + assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO); + assert(pos.piece_count(weakerSide, PAWN) == VALUE_ZERO); assert(pos.non_pawn_material(strongerSide) == KnightValueMidgame + BishopValueMidgame); assert(pos.piece_count(strongerSide, BISHOP) == 1); assert(pos.piece_count(strongerSide, KNIGHT) == 1); @@ -152,7 +152,10 @@ Value EvaluationFunction::apply(const Position& pos) const { Square loserKSq = pos.king_square(weakerSide); Square bishopSquare = pos.piece_list(strongerSide, BISHOP, 0); - if (same_color_squares(bishopSquare, SQ_A1)) + // kbnk_mate_table() tries to drive toward corners A1 or H8, + // if we have a bishop that cannot reach the above squares we + // mirror the kings so to drive enemy toward corners A8 or H1. + if (!same_color_squares(bishopSquare, SQ_A1)) { winnerKSq = flop_square(winnerKSq); loserKSq = flop_square(loserKSq); @@ -170,8 +173,8 @@ Value EvaluationFunction::apply(const Position& pos) const { template<> Value EvaluationFunction::apply(const Position& pos) const { - assert(pos.non_pawn_material(strongerSide) == Value(0)); - assert(pos.non_pawn_material(weakerSide) == Value(0)); + assert(pos.non_pawn_material(strongerSide) == VALUE_ZERO); + assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO); assert(pos.piece_count(strongerSide, PAWN) == 1); assert(pos.piece_count(weakerSide, PAWN) == 0); @@ -364,12 +367,12 @@ Value EvaluationFunction::apply(const Position& pos) const { /// king alone are always draw. template<> Value EvaluationFunction::apply(const Position&) const { - return Value(0); + return VALUE_ZERO; } template<> Value EvaluationFunction::apply(const Position&) const { - return Value(0); + return VALUE_ZERO; } /// KBPKScalingFunction scales endgames where the stronger side has king, @@ -622,9 +625,9 @@ ScaleFactor ScalingFunction::apply(const Position& pos) const { template<> ScaleFactor ScalingFunction::apply(const Position& pos) const { - assert(pos.non_pawn_material(strongerSide) == Value(0)); + assert(pos.non_pawn_material(strongerSide) == VALUE_ZERO); assert(pos.piece_count(strongerSide, PAWN) >= 2); - assert(pos.non_pawn_material(weakerSide) == Value(0)); + assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO); assert(pos.piece_count(weakerSide, PAWN) == 0); Square ksq = pos.king_square(weakerSide); @@ -821,7 +824,7 @@ ScaleFactor ScalingFunction::apply(const Position& pos) const { assert(pos.non_pawn_material(strongerSide) == KnightValueMidgame); assert(pos.piece_count(strongerSide, KNIGHT) == 1); assert(pos.piece_count(strongerSide, PAWN) == 1); - assert(pos.non_pawn_material(weakerSide) == Value(0)); + assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO); assert(pos.piece_count(weakerSide, PAWN) == 0); Square pawnSq = pos.piece_list(strongerSide, PAWN, 0); @@ -848,8 +851,8 @@ ScaleFactor ScalingFunction::apply(const Position& pos) const { template<> ScaleFactor ScalingFunction::apply(const Position& pos) const { - assert(pos.non_pawn_material(strongerSide) == Value(0)); - assert(pos.non_pawn_material(weakerSide) == Value(0)); + assert(pos.non_pawn_material(strongerSide) == VALUE_ZERO); + assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO); assert(pos.piece_count(WHITE, PAWN) == 1); assert(pos.piece_count(BLACK, PAWN) == 1);