]> git.sesse.net Git - stockfish/commitdiff
Skip a couple of popcount in previous patch
authorMarco Costalba <mcostalba@gmail.com>
Fri, 19 Apr 2013 07:41:28 +0000 (09:41 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 19 Apr 2013 08:31:18 +0000 (10:31 +0200)
And some little tidy up

No functional change.

src/bitboard.h
src/evaluate.cpp
src/pawns.cpp
src/pawns.h

index 142c4c5a397f85b5b9092b4692c374cd1c6a2f01..a53f348b2fb268eb412bebbdfc967c6f70b5b072 100644 (file)
@@ -63,7 +63,6 @@ extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];
 extern Bitboard AttackSpanMask[COLOR_NB][SQUARE_NB];
 extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
 
 extern Bitboard AttackSpanMask[COLOR_NB][SQUARE_NB];
 extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
 
-const Bitboard WhiteSquares = 0x55AA55AA55AA55AAULL;
 const Bitboard BlackSquares = 0xAA55AA55AA55AA55ULL;
 
 /// Overloads of bitwise operators between a Bitboard and a Square for testing
 const Bitboard BlackSquares = 0xAA55AA55AA55AA55ULL;
 
 /// Overloads of bitwise operators between a Bitboard and a Square for testing
@@ -201,8 +200,7 @@ inline bool squares_aligned(Square s1, Square s2, Square s3) {
 /// the same color of the given square.
 
 inline Bitboard same_color_squares(Square s) {
 /// the same color of the given square.
 
 inline Bitboard same_color_squares(Square s) {
-  return Bitboard(0xAA55AA55AA55AA55ULL) & s ?  0xAA55AA55AA55AA55ULL
-                                             : ~0xAA55AA55AA55AA55ULL;
+  return BlackSquares & s ? BlackSquares : ~BlackSquares;
 }
 
 
 }
 
 
index dd26e46986e9ad7fb57829ddf4ed5f3992f349cc..aeaae07f10720114be0986e93b91d37f6ee41200 100644 (file)
@@ -171,6 +171,9 @@ namespace {
   // right to castle.
   const Value TrappedRookPenalty = Value(180);
 
   // right to castle.
   const Value TrappedRookPenalty = Value(180);
 
+  // Penalty for bishop with pawns on the same coloured squares
+  const Score BishopPawnsPenalty = make_score(8, 12);
+
   // Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by
   // a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only
   // happen in Chess960 games.
   // Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by
   // a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only
   // happen in Chess960 games.
@@ -584,7 +587,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
 
         // Penalty for bishop with same coloured pawns
         if (Piece == BISHOP)
 
         // Penalty for bishop with same coloured pawns
         if (Piece == BISHOP)
-            score -= make_score(8, 12) * ei.pi->same_colored_pawn_count(s, Us); 
+            score -= BishopPawnsPenalty * ei.pi->pawns_on_same_color_squares(Us, s);
 
         // Bishop and knight outposts squares
         if (    (Piece == BISHOP || Piece == KNIGHT)
 
         // Bishop and knight outposts squares
         if (    (Piece == BISHOP || Piece == KNIGHT)
index 3d99bfc68645a3e327554eef3fc2e067755a1297..5b64ac6163091814e53150544b2add49c93e10b0 100644 (file)
@@ -176,11 +176,11 @@ namespace {
             value += CandidateBonus[relative_rank(Us, s)];
     }
 
             value += CandidateBonus[relative_rank(Us, s)];
     }
 
-    e->pawnsOnWhiteSquaresCount[Us]   = popcount<Max15>(ourPawns   & WhiteSquares);
-    e->pawnsOnWhiteSquaresCount[Them] = popcount<Max15>(theirPawns & WhiteSquares);
+    e->pawnsOnSquares[Us][BLACK] = popcount<Max15>(ourPawns & BlackSquares);
+    e->pawnsOnSquares[Us][WHITE] = pos.piece_count(Us, PAWN) - e->pawnsOnSquares[Us][BLACK];
 
 
-    e->pawnsOnBlackSquaresCount[Us]   = popcount<Max15>(ourPawns   & BlackSquares);
-    e->pawnsOnBlackSquaresCount[Them] = popcount<Max15>(theirPawns & BlackSquares); 
+    e->pawnsOnSquares[Them][BLACK] = popcount<Max15>(theirPawns & BlackSquares);
+    e->pawnsOnSquares[Them][WHITE] = pos.piece_count(Them, PAWN) - e->pawnsOnSquares[Them][BLACK];
 
     return value;
   }
 
     return value;
   }
index 3ec62334c96d28cbf68e0a4184d3c4f5da2df780..293869bc777c6ed39c4d42d7f78858c18345de44 100644 (file)
@@ -40,7 +40,7 @@ struct Entry {
   int file_is_half_open(Color c, File f) const { return halfOpenFiles[c] & (1 << int(f)); }
   int has_open_file_to_left(Color c, File f) const { return halfOpenFiles[c] & ((1 << int(f)) - 1); }
   int has_open_file_to_right(Color c, File f) const { return halfOpenFiles[c] & ~((1 << int(f+1)) - 1); }
   int file_is_half_open(Color c, File f) const { return halfOpenFiles[c] & (1 << int(f)); }
   int has_open_file_to_left(Color c, File f) const { return halfOpenFiles[c] & ((1 << int(f)) - 1); }
   int has_open_file_to_right(Color c, File f) const { return halfOpenFiles[c] & ~((1 << int(f+1)) - 1); }
-  int same_colored_pawn_count(Square s, Color c) const { return (BlackSquares & s) ? pawnsOnBlackSquaresCount[c] : pawnsOnWhiteSquaresCount[c]; } 
+  int pawns_on_same_color_squares(Color c, Square s) const { return pawnsOnSquares[c][!!(BlackSquares & s)]; }
 
   template<Color Us>
   Score king_safety(const Position& pos, Square ksq)  {
 
   template<Color Us>
   Score king_safety(const Position& pos, Square ksq)  {
@@ -64,8 +64,7 @@ struct Entry {
   Score value;
   int halfOpenFiles[COLOR_NB];
   Score kingSafety[COLOR_NB];
   Score value;
   int halfOpenFiles[COLOR_NB];
   Score kingSafety[COLOR_NB];
-  int pawnsOnWhiteSquaresCount[COLOR_NB];
-  int pawnsOnBlackSquaresCount[COLOR_NB];
+  int pawnsOnSquares[COLOR_NB][COLOR_NB];
 };
 
 typedef HashTable<Entry, 16384> Table;
 };
 
 typedef HashTable<Entry, 16384> Table;