X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=f1f29d61249371f9302d51d4c93ae3049489991d;hp=ec54d4e69ea5114265e0d47d05a4fd0cc68f2c4b;hb=cdfe43eb8ff6f8b4315442318a4259deb4614167;hpb=b46bf2950f76696fb965c79c5c95ffd7177268ac diff --git a/src/endgame.cpp b/src/endgame.cpp index ec54d4e6..f1f29d61 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -77,7 +77,7 @@ namespace { string fen = sides[0] + char('0' + int(8 - code.length())) + sides[1] + "/8/8/8/8/8/8/8 w - - 0 10"; - return Position(fen, false, 0).material_key(); + return Position(fen, false, NULL).material_key(); } template @@ -116,10 +116,8 @@ Endgames::~Endgames() { template void Endgames::add(const string& code) { - typedef typename eg_family::type T; - - map((T*)0)[key(code, WHITE)] = new Endgame(WHITE); - map((T*)0)[key(code, BLACK)] = new Endgame(BLACK); + map((Endgame*)0)[key(code, WHITE)] = new Endgame(WHITE); + map((Endgame*)0)[key(code, BLACK)] = new Endgame(BLACK); } @@ -133,13 +131,13 @@ Value Endgame::operator()(const Position& pos) const { assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO); assert(pos.piece_count(weakerSide, PAWN) == VALUE_ZERO); - // Stalemate detection with lone king + // Stalemate detection with lone king if ( pos.side_to_move() == weakerSide && !pos.in_check() && !MoveList(pos).size()) { return VALUE_DRAW; } - + Square winnerKSq = pos.king_square(strongerSide); Square loserKSq = pos.king_square(weakerSide); @@ -150,7 +148,7 @@ Value Endgame::operator()(const Position& pos) const { if ( pos.piece_count(strongerSide, QUEEN) || pos.piece_count(strongerSide, ROOK) - || pos.both_color_bishops(strongerSide)) { + || pos.bishop_pair(strongerSide)) { result += VALUE_KNOWN_WIN; } @@ -412,7 +410,7 @@ ScaleFactor Endgame::operator()(const Position& pos) const { File pawnFile = file_of(pos.piece_list(strongerSide, PAWN)[0]); // All pawns are on a single rook file ? - if ( (pawnFile == FILE_A || pawnFile == FILE_H) + if ( (pawnFile == FILE_A || pawnFile == FILE_H) && !(pawns & ~file_bb(pawnFile))) { Square bishopSq = pos.piece_list(strongerSide, BISHOP)[0]; @@ -652,7 +650,7 @@ ScaleFactor Endgame::operator()(const Position& pos) const { { // Does the defending king block the pawns? if ( square_distance(ksq, relative_square(strongerSide, SQ_A8)) <= 1 - || ( file_of(ksq) == FILE_A + || ( file_of(ksq) == FILE_A && !in_front_bb(strongerSide, ksq) & pawns)) return SCALE_FACTOR_DRAW; } @@ -661,7 +659,7 @@ ScaleFactor Endgame::operator()(const Position& pos) const { { // Does the defending king block the pawns? if ( square_distance(ksq, relative_square(strongerSide, SQ_H8)) <= 1 - || ( file_of(ksq) == FILE_H + || ( file_of(ksq) == FILE_H && !in_front_bb(strongerSide, ksq) & pawns)) return SCALE_FACTOR_DRAW; } @@ -712,7 +710,7 @@ ScaleFactor Endgame::operator()(const Position& pos) const { return SCALE_FACTOR_DRAW; else { - Bitboard path = squares_in_front_of(strongerSide, pawnSq); + Bitboard path = forward_bb(strongerSide, pawnSq); if (path & pos.pieces(KING, weakerSide)) return SCALE_FACTOR_DRAW;