X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=e0efd0e665271b75f2fc6bab5b824b97f843de89;hp=913be63f1702c21eb4d76277c2cc4a6daaeb3954;hb=611a29f7675d3e5dc7e5e2b63cca9274eae05578;hpb=94b9c65e09b5d396bebb29b62d9979139b5fbdfa diff --git a/src/endgame.cpp b/src/endgame.cpp index 913be63f..e0efd0e6 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -24,7 +24,6 @@ #include -#include "bitbase.h" #include "bitcount.h" #include "endgame.h" @@ -102,6 +101,7 @@ namespace { /// init_bitbases() is called during program initialization, and simply loads /// bitbases from disk into memory. At the moment, there is only the bitbase /// for KP vs K, but we may decide to add other bitbases later. +extern void generate_kpk_bitbase(uint8_t bitbase[]); void init_bitbases() { generate_kpk_bitbase(KPKBitbase); @@ -357,7 +357,7 @@ Value EvaluationFunction::apply(const Position& pos) const { result += Value(square_distance(bksq, nsq) * 32); // Bonus for restricting the knight's mobility - result += Value((8 - count_1s_max_15(pos.attacks_from(nsq))) * 8); + result += Value((8 - count_1s(pos.attacks_from(nsq))) * 8); return strongerSide == pos.side_to_move() ? result : -result; } @@ -367,12 +367,12 @@ Value EvaluationFunction::apply(const Position& pos) const { /// king alone are always draw. template<> Value EvaluationFunction::apply(const Position&) const { - return VALUE_ZERO; + return VALUE_DRAW; } template<> Value EvaluationFunction::apply(const Position&) const { - return VALUE_ZERO; + return VALUE_DRAW; } /// KBPKScalingFunction scales endgames where the stronger side has king, @@ -699,11 +699,12 @@ ScaleFactor ScalingFunction::apply(const Position& pos) const { return SCALE_FACTOR_ZERO; else { - Bitboard ray = ray_bb(pawnSq, (strongerSide == WHITE)? SIGNED_DIR_N : SIGNED_DIR_S); - if (ray & pos.pieces(KING, weakerSide)) + Bitboard path = squares_in_front_of(strongerSide, pawnSq); + + if (path & pos.pieces(KING, weakerSide)) return SCALE_FACTOR_ZERO; - if ( (pos.attacks_from(weakerBishopSq) & ray) + if ( (pos.attacks_from(weakerBishopSq) & path) && square_distance(weakerBishopSq, pawnSq) >= 3) return SCALE_FACTOR_ZERO; }