]> git.sesse.net Git - stockfish/commitdiff
Move pawnsOnSquares to Position (#2100)
authorprotonspring <mike@whiteley.org>
Tue, 16 Apr 2019 21:10:53 +0000 (15:10 -0600)
committerMarco Costalba <mcostalba@users.noreply.github.com>
Tue, 16 Apr 2019 21:10:53 +0000 (23:10 +0200)
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
src/pawns.cpp
src/pawns.h
src/position.h

index fbe768bbbd4d72983fd1abd312ec7c31ba881c58..566eba6d93433659afa89898dac49de293c50cbb 100644 (file)
@@ -328,7 +328,7 @@ namespace {
                 // bishop, bigger when the center files are blocked with pawns.
                 Bitboard blocked = pos.pieces(Us, PAWN) & shift<Down>(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
index 4c2ff3913d50faecad5cbc081e5e6b27428cb45a..e2b26344986ad51d129aafbf9fba91ba8d2857fc 100644 (file)
@@ -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<Us>(ourPawns);
-    e->pawnsOnSquares[Us][BLACK] = popcount(ourPawns & DarkSquares);
-    e->pawnsOnSquares[Us][WHITE] = pos.count<PAWN>(Us) - e->pawnsOnSquares[Us][BLACK];
 
     // Loop through all pawns of the current color and score each pawn
     while ((s = *pl++) != SQ_NONE)
index 96ed4149216fc24527e920d86c4e0ed5ab477122..88b5554537e72a935606d0665a0f1668838f26a4 100644 (file)
@@ -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<Color Us>
   Score king_safety(const Position& pos) {
     return  kingSquares[Us] == pos.square<KING>(Us) && castlingRights[Us] == pos.castling_rights(Us)
index 1351d0d125a6b60a4d14d78aaf071af638417b92..1078e03ed75fa5a4aa42bed002f0d7f820517c09 100644 (file)
@@ -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;
 }