From 3b46df546dd8b17963abae887acff6e91e2b945e Mon Sep 17 00:00:00 2001 From: protonspring Date: Tue, 16 Apr 2019 15:10:53 -0600 Subject: [PATCH] Move pawnsOnSquares to Position (#2100) We can remove the values in Pawns if we just use the piece arrays in Position. This reduces the size of a pawn entry. This simplification passed individually, and in concert with ps_passedcount100 (removes passedCount storage in pawns.). STC LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 19957 W: 4529 L: 4404 D: 11024 http://tests.stockfishchess.org/tests/view/5cb3c2d00ebc5925cf016f0d Combo STC LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 17368 W: 3925 L: 3795 D: 9648 http://tests.stockfishchess.org/tests/view/5cb3d3510ebc5925cf01709a This is a non-functional simplification. --- src/evaluate.cpp | 2 +- src/pawns.cpp | 2 -- src/pawns.h | 4 ---- src/position.h | 5 +++++ 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index fbe768bb..566eba6d 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -328,7 +328,7 @@ namespace { // bishop, bigger when the center files are blocked with pawns. Bitboard blocked = pos.pieces(Us, PAWN) & shift(pos.pieces()); - score -= BishopPawns * pe->pawns_on_same_color_squares(Us, s) + score -= BishopPawns * pos.pawns_on_same_color_squares(Us, s) * (1 + popcount(blocked & CenterFiles)); // Bonus for bishop on a long diagonal which can "see" both center squares diff --git a/src/pawns.cpp b/src/pawns.cpp index 4c2ff391..e2b26344 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -79,8 +79,6 @@ namespace { e->passedPawns[Us] = e->pawnAttacksSpan[Us] = e->weakUnopposed[Us] = 0; e->kingSquares[Us] = SQ_NONE; e->pawnAttacks[Us] = pawn_attacks_bb(ourPawns); - e->pawnsOnSquares[Us][BLACK] = popcount(ourPawns & DarkSquares); - e->pawnsOnSquares[Us][WHITE] = pos.count(Us) - e->pawnsOnSquares[Us][BLACK]; // Loop through all pawns of the current color and score each pawn while ((s = *pl++) != SQ_NONE) diff --git a/src/pawns.h b/src/pawns.h index 96ed4149..88b55545 100644 --- a/src/pawns.h +++ b/src/pawns.h @@ -40,10 +40,6 @@ struct Entry { int weak_unopposed(Color c) const { return weakUnopposed[c]; } int passed_count() const { return popcount(passedPawns[WHITE] | passedPawns[BLACK]); }; - int pawns_on_same_color_squares(Color c, Square s) const { - return pawnsOnSquares[c][bool(DarkSquares & s)]; - } - template Score king_safety(const Position& pos) { return kingSquares[Us] == pos.square(Us) && castlingRights[Us] == pos.castling_rights(Us) diff --git a/src/position.h b/src/position.h index 1351d0d1..1078e03e 100644 --- a/src/position.h +++ b/src/position.h @@ -129,6 +129,7 @@ public: // Piece specific bool pawn_passed(Color c, Square s) const; bool opposite_bishops() const; + int pawns_on_same_color_squares(Color c, Square s) const; // Doing and undoing moves void do_move(Move m, StateInfo& newSt); @@ -323,6 +324,10 @@ inline bool Position::advanced_pawn_push(Move m) const { && relative_rank(sideToMove, from_sq(m)) > RANK_4; } +inline int Position::pawns_on_same_color_squares(Color c, Square s) const { + return popcount(pieces(c, PAWN) & ((DarkSquares & s) ? DarkSquares : ~DarkSquares)); +} + inline Key Position::key() const { return st->key; } -- 2.39.2