]> git.sesse.net Git - stockfish/commitdiff
Give a small penalty for bishop for each pawn on the same colored square
authorJoona Kiiski <joona.kiiski@gmail.com>
Tue, 16 Apr 2013 20:20:31 +0000 (21:20 +0100)
committerJoona Kiiski <joona.kiiski@gmail.com>
Tue, 16 Apr 2013 20:20:31 +0000 (21:20 +0100)
src/bitboard.h
src/evaluate.cpp
src/material.cpp
src/pawns.cpp
src/pawns.h

index 2c51b073de3042ec1e7f1cf455b9d247ac927cd9..142c4c5a397f85b5b9092b4692c374cd1c6a2f01 100644 (file)
@@ -63,6 +63,8 @@ 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
 /// whether a given bit is set in a bitboard, and for setting and clearing bits.
 
 /// Overloads of bitwise operators between a Bitboard and a Square for testing
 /// whether a given bit is set in a bitboard, and for setting and clearing bits.
index 6990a71d2bbb306d945cfedebc94c659e1497475..3481b03d7c77ad2a01622eb7abd1960ffab7ca4a 100644 (file)
@@ -582,6 +582,10 @@ Value do_evaluate(const Position& pos, Value& margin) {
                  && !more_than_one(BetweenBB[s][pos.king_square(Them)] & pos.pieces()))
                  score += BishopPinBonus;
 
                  && !more_than_one(BetweenBB[s][pos.king_square(Them)] & pos.pieces()))
                  score += BishopPinBonus;
 
+        // Penalty for bishop with same coloured pawns
+        if (Piece == BISHOP)
+            score -= make_score(4, 4) * ei.pi->same_colored_pawn_count(s, Us); 
+
         // Bishop and knight outposts squares
         if (    (Piece == BISHOP || Piece == KNIGHT)
             && !(pos.pieces(Them, PAWN) & attack_span_mask(Us, s)))
         // Bishop and knight outposts squares
         if (    (Piece == BISHOP || Piece == KNIGHT)
             && !(pos.pieces(Them, PAWN) & attack_span_mask(Us, s)))
index 9cc8eeadc470b7e2f20a9f91a9c5ee8a4c1f9568..3474ccd576c5e613c7fd3373b0e71edf6fd1ca1c 100644 (file)
@@ -39,7 +39,7 @@ namespace {
   const Value RedundantRookPenalty  = Value(554);
 
   //                                  pair  pawn knight bishop rook queen
   const Value RedundantRookPenalty  = Value(554);
 
   //                                  pair  pawn knight bishop rook queen
-  const int LinearCoefficients[6] = { 1617, -162, -1172, -190,  105,  26 };
+  const int LinearCoefficients[6] = { 1617, -162, -1172,  -62,  105,  26 };
 
   const int QuadraticCoefficientsSameColor[][PIECE_TYPE_NB] = {
     // pair pawn knight bishop rook queen
 
   const int QuadraticCoefficientsSameColor[][PIECE_TYPE_NB] = {
     // pair pawn knight bishop rook queen
index c1a93169bd7e394f3b3abffb1234a122864e479d..3d99bfc68645a3e327554eef3fc2e067755a1297 100644 (file)
@@ -176,6 +176,12 @@ 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->pawnsOnBlackSquaresCount[Us]   = popcount<Max15>(ourPawns   & BlackSquares);
+    e->pawnsOnBlackSquaresCount[Them] = popcount<Max15>(theirPawns & BlackSquares); 
+
     return value;
   }
 }
     return value;
   }
 }
index 2c04e7d2eaa7ecf75fb09cc906446173232a613d..3ec62334c96d28cbf68e0a4184d3c4f5da2df780 100644 (file)
@@ -40,6 +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]; } 
 
   template<Color Us>
   Score king_safety(const Position& pos, Square ksq)  {
 
   template<Color Us>
   Score king_safety(const Position& pos, Square ksq)  {
@@ -63,6 +64,8 @@ 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];
 };
 
 typedef HashTable<Entry, 16384> Table;
 };
 
 typedef HashTable<Entry, 16384> Table;