X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=836621d2a5428f02e220bd8c643005e6a21e4cc9;hp=fd4c92f708e61ac14d4ffa1e1a6ab68ad00fad76;hb=e53774bc49dd0aaa1c129ee98c09e1a56ef974fb;hpb=3fda064a669c2bcecfa31d66c661efa7408499de diff --git a/src/endgame.cpp b/src/endgame.cpp index fd4c92f7..836621d2 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -1,7 +1,7 @@ /* Stockfish, a UCI chess playing engine derived from Glaurung 2.1 Copyright (C) 2004-2008 Tord Romstad (Glaurung author) - Copyright (C) 2008-2014 Marco Costalba, Joona Kiiski, Tord Romstad + Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, 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 @@ -96,12 +96,9 @@ 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, NULL).material_key(); + return Position(fen, false, nullptr).material_key(); } - template - void delete_endgame(const typename M::value_type& p) { delete p.second; } - } // namespace @@ -128,17 +125,11 @@ Endgames::Endgames() { add("KRPPKRP"); } -Endgames::~Endgames() { - - for_each(m1.begin(), m1.end(), delete_endgame); - for_each(m2.begin(), m2.end(), delete_endgame); -} -template +template void Endgames::add(const string& code) { - - map((Endgame*)0)[key(code, WHITE)] = new Endgame(WHITE); - map((Endgame*)0)[key(code, BLACK)] = new Endgame(BLACK); + map()[key(code, WHITE)] = std::unique_ptr>(new Endgame(WHITE)); + map()[key(code, BLACK)] = std::unique_ptr>(new Endgame(BLACK)); } @@ -167,7 +158,8 @@ Value Endgame::operator()(const Position& pos) const { if ( pos.count(strongSide) || pos.count(strongSide) ||(pos.count(strongSide) && pos.count(strongSide)) - || pos.bishop_pair(strongSide)) + ||(pos.count(strongSide) > 1 && opposite_colors(pos.list(strongSide)[0], + pos.list(strongSide)[1]))) result += VALUE_KNOWN_WIN; return strongSide == pos.side_to_move() ? result : -result;