X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpawns.cpp;h=7d39a4a08bde360f2299f3cc231817e0d749ac07;hp=75b94c19c0d012e1a00e7e3abc98d644afb4072b;hb=39257509452a81db28538462e6581b05d1a4b7fb;hpb=767c4ad1fc487b72240006c888aaf8c00006cd82 diff --git a/src/pawns.cpp b/src/pawns.cpp index 75b94c19..7d39a4a0 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -2,7 +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-2018 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad + Copyright (C) 2015-2019 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 @@ -58,10 +58,6 @@ namespace { { V(-10), V(-14), V( 90), V(15), V( 2), V( -7), V(-16) } }; - // Danger of blocked enemy pawns storming our king, by rank - constexpr Value BlockedStorm[RANK_NB] = - { V(0), V(0), V(66), V(6), V(5), V(1), V(15) }; - #undef S #undef V @@ -225,7 +221,7 @@ Value Entry::evaluate_shelter(const Position& pos, Square ksq) { int d = std::min(f, ~f); safety += ShelterStrength[d][ourRank]; - safety -= (ourRank && (ourRank == theirRank - 1)) ? BlockedStorm[theirRank] + safety -= (ourRank && (ourRank == theirRank - 1)) ? 66 * (theirRank == RANK_3) : UnblockedStorm[d][theirRank]; } @@ -237,8 +233,9 @@ Value Entry::evaluate_shelter(const Position& pos, Square ksq) { /// when king square changes, which is about 20% of total king_safety() calls. template -Score Entry::do_king_safety(const Position& pos, Square ksq) { +Score Entry::do_king_safety(const Position& pos) { + Square ksq = pos.square(Us); kingSquares[Us] = ksq; castlingRights[Us] = pos.can_castle(Us); int minKingPawnDistance = 0; @@ -250,17 +247,17 @@ Score Entry::do_king_safety(const Position& pos, Square ksq) { Value bonus = evaluate_shelter(pos, ksq); // If we can castle use the bonus after the castling if it is bigger - if (pos.can_castle(MakeCastling::right)) + if (pos.can_castle(Us | KING_SIDE)) bonus = std::max(bonus, evaluate_shelter(pos, relative_square(Us, SQ_G1))); - if (pos.can_castle(MakeCastling::right)) + if (pos.can_castle(Us | QUEEN_SIDE)) bonus = std::max(bonus, evaluate_shelter(pos, relative_square(Us, SQ_C1))); return make_score(bonus, -16 * minKingPawnDistance); } // Explicit template instantiation -template Score Entry::do_king_safety(const Position& pos, Square ksq); -template Score Entry::do_king_safety(const Position& pos, Square ksq); +template Score Entry::do_king_safety(const Position& pos); +template Score Entry::do_king_safety(const Position& pos); } // namespace Pawns