From: mstembera Date: Sun, 11 Nov 2018 03:49:13 +0000 (-0800) Subject: Remove redundant king square parameter X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=68209c9121b54760f03e5f00d6698bca190706ed;hp=30a905c95d0b77874244c8b68ae77daba41ac545 Remove redundant king square parameter We don't need to pass the king square as an explicit parameter to the functions king_safety() and do_king_safety() since we already pass in the position. STC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 69686 W: 14894 L: 14866 D: 39926 http://tests.stockfishchess.org/tests/view/5be84ac20ebc595e0ae3283c No functional change. --- diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 97218baa..6128b45f 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -415,7 +415,7 @@ namespace { Bitboard kingFlank, weak, b, b1, b2, safe, unsafeChecks; // King shelter and enemy pawns storm - Score score = pe->king_safety(pos, ksq); + Score score = pe->king_safety(pos); // Find the squares that opponent attacks in our king flank, and the squares // which are attacked twice in that flank but not defended by our pawns. diff --git a/src/pawns.cpp b/src/pawns.cpp index 36b10f32..98e13f83 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -237,8 +237,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; @@ -260,7 +261,7 @@ Score Entry::do_king_safety(const Position& pos, Square ksq) { } // 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 diff --git a/src/pawns.h b/src/pawns.h index ec926a42..5129df03 100644 --- a/src/pawns.h +++ b/src/pawns.h @@ -50,13 +50,13 @@ struct Entry { } template - Score king_safety(const Position& pos, Square ksq) { - return kingSquares[Us] == ksq && castlingRights[Us] == pos.can_castle(Us) - ? kingSafety[Us] : (kingSafety[Us] = do_king_safety(pos, ksq)); + Score king_safety(const Position& pos) { + return kingSquares[Us] == pos.square(Us) && castlingRights[Us] == pos.can_castle(Us) + ? kingSafety[Us] : (kingSafety[Us] = do_king_safety(pos)); } template - Score do_king_safety(const Position& pos, Square ksq); + Score do_king_safety(const Position& pos); template Value evaluate_shelter(const Position& pos, Square ksq);