X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=abbb0876c64bd35b77be6f919ca66b793d02c4cb;hp=90898e8341a58987b46cb0433018cb4d587484e8;hb=aa925a0e2905042a978860a75798398cb79b2600;hpb=3376c68f4bb83dc9fd874eb9d710dab09609ae54 diff --git a/src/endgame.cpp b/src/endgame.cpp index 90898e83..abbb0876 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -29,41 +29,6 @@ #include "endgame.h" -//// -//// Constants and variables -//// - -/// Evaluation functions - -// Generic "mate lone king" eval -EvaluationFunction EvaluateKXK(WHITE), EvaluateKKX(BLACK); - -// K and two minors vs K and one or two minors -EvaluationFunction EvaluateKmmKm(WHITE); - -EvaluationFunction EvaluateKBNK(WHITE), EvaluateKKBN(BLACK); // KBN vs K -EvaluationFunction EvaluateKPK(WHITE), EvaluateKKP(BLACK); // KP vs K -EvaluationFunction EvaluateKRKP(WHITE), EvaluateKPKR(BLACK); // KR vs KP -EvaluationFunction EvaluateKRKB(WHITE), EvaluateKBKR(BLACK); // KR vs KB -EvaluationFunction EvaluateKRKN(WHITE), EvaluateKNKR(BLACK); // KR vs KN -EvaluationFunction EvaluateKQKR(WHITE), EvaluateKRKQ(BLACK); // KQ vs KR -EvaluationFunction EvaluateKBBKN(WHITE), EvaluateKNKBB(BLACK); // KBB vs KN - - -/// Scaling functions - -ScalingFunction ScaleKBPK(WHITE), ScaleKKBP(BLACK); // KBP vs K -ScalingFunction ScaleKQKRP(WHITE), ScaleKRPKQ(BLACK); // KQ vs KRP -ScalingFunction ScaleKRPKR(WHITE), ScaleKRKRP(BLACK); // KRP vs KR -ScalingFunction ScaleKRPPKRP(WHITE), ScaleKRPKRPP(BLACK); // KRPP vs KRP -ScalingFunction ScaleKPsK(WHITE), ScaleKKPs(BLACK); // King and pawns vs king -ScalingFunction ScaleKBPKB(WHITE), ScaleKBKBP(BLACK); // KBP vs KB -ScalingFunction ScaleKBPPKB(WHITE), ScaleKBKBPP(BLACK); // KBPP vs KB -ScalingFunction ScaleKBPKN(WHITE), ScaleKNKBP(BLACK); // KBP vs KN -ScalingFunction ScaleKNPK(WHITE), ScaleKKNP(BLACK); // KNP vs K -ScalingFunction ScaleKPKPw(WHITE), ScaleKPKPb(BLACK); // KPKP - - //// //// Local definitions //// @@ -378,16 +343,23 @@ Value EvaluationFunction::apply(const Position& pos) { result += Value(square_distance(bksq, nsq) * 32); // Bonus for restricting the knight's mobility - result += Value((8 - count_1s_max_15(pos.piece_attacks(nsq))) * 8); + result += Value((8 - count_1s_max_15(pos.piece_attacks(nsq))) * 8); return (strongerSide == pos.side_to_move() ? result : -result); } + +/// K and two minors vs K and one or two minors or K and two knights against +/// king alone are always draw. template<> Value EvaluationFunction::apply(const Position&) { return Value(0); } +template<> +Value EvaluationFunction::apply(const Position&) { + return Value(0); +} /// KBPKScalingFunction scales endgames where the stronger side has king, /// bishop and one or more pawns. It checks for draws with rook pawns and a