X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=04469e87b4ea3f23d09d22852bd7b152370904d4;hp=ed6d48db13fcf1c6b5fc9b9af6aab626337f10e7;hb=b96dd754ede60b8463606cf38eac3eab400a123d;hpb=3428a2875197c805c25fdd954ba3a24d00845a2a diff --git a/src/endgame.cpp b/src/endgame.cpp index ed6d48db..04469e87 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -2,6 +2,7 @@ Stockfish, a UCI chess playing engine derived from Glaurung 2.1 Copyright (C) 2004-2008 Tord Romstad (Glaurung author) Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad + Copyright (C) 2015-2016 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad Stockfish is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,7 +22,6 @@ #include #include "bitboard.h" -#include "bitcount.h" #include "endgame.h" #include "movegen.h" @@ -39,7 +39,7 @@ namespace { 70, 50, 30, 20, 20, 30, 50, 70, 80, 60, 40, 30, 30, 40, 60, 80, 90, 70, 60, 50, 50, 60, 70, 90, - 100, 90, 80, 70, 70, 80, 90, 100, + 100, 90, 80, 70, 70, 80, 90, 100 }; // Table used to drive the king towards a corner square of the @@ -60,7 +60,7 @@ namespace { const int PushAway [8] = { 0, 5, 20, 40, 60, 80, 90, 100 }; // Pawn Rank based scaling factors used in KRPPKRP endgame - const int KRPPKRPScaleFactors[RANK_NB] = {0, 9, 10, 14, 21, 44, 0, 0}; + const int KRPPKRPScaleFactors[RANK_NB] = { 0, 9, 10, 14, 21, 44, 0, 0 }; #ifndef NDEBUG bool verify_material(const Position& pos, Color c, Value npm, int pawnsCnt) { @@ -99,7 +99,8 @@ namespace { string fen = sides[0] + char(8 - sides[0].length() + '0') + "/8/8/8/8/8/8/" + sides[1] + char(8 - sides[1].length() + '0') + " w - - 0 10"; - return Position(fen, false, nullptr).material_key(); + StateInfo st; + return Position().set(fen, false, &st, nullptr).material_key(); } } // namespace @@ -163,7 +164,7 @@ Value Endgame::operator()(const Position& pos) const { ||(pos.count(strongSide) && pos.count(strongSide)) ||(pos.count(strongSide) > 1 && opposite_colors(pos.squares(strongSide)[0], pos.squares(strongSide)[1]))) - result += VALUE_KNOWN_WIN; + result = std::min(result + VALUE_KNOWN_WIN, VALUE_MATE_IN_MAX_PLY - 1); return strongSide == pos.side_to_move() ? result : -result; }