]> git.sesse.net Git - stockfish/commitdiff
Assorted code-style triviality
authorMarco Costalba <mcostalba@gmail.com>
Sun, 9 Nov 2014 08:24:06 +0000 (09:24 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 9 Nov 2014 19:17:29 +0000 (20:17 +0100)
No functional change.

src/evaluate.cpp
src/search.cpp
src/tt.cpp
src/types.h

index fe02ca29efc07cf59327428819154bf0ae0728a0..8cc481726b0760d445dc191ecb5b6f3e7687ac7b 100644 (file)
@@ -137,13 +137,13 @@ namespace {
     V(0), V(5), V(8), V(8), V(8), V(8), V(5), V(0) }
   };
 
-  // Threat[attacking][attacked] contains bonuses according to which piece
-  // type attacks which one.
-  const Score Threat[][PIECE_TYPE_NB] = {
-    { S(0, 0), S( 0, 0), S(19, 37), S(24, 37), S(44, 97), S(35,106) }, // Protected Minor attacks
-    { S(0, 0), S( 0, 0), S( 9, 14), S( 9, 14), S( 7, 14), S(24, 48) }, // Protected Major attacks
-    { S(0, 0), S( 0,32), S(33, 41), S(31, 50), S(41,100), S(35,104) }, // Weak Minor attacks
-    { S(0, 0), S( 0,27), S(26, 57), S(26, 57), S(0 , 43), S(23, 51) }  // Weak Major attacks
+  // Threat[defended/weak][minor/major attacking][attacked PieceType] contains
+  // bonuses according to which piece type attacks which one.
+  const Score Threat[][2][PIECE_TYPE_NB] = {
+  { { S(0, 0), S( 0, 0), S(19, 37), S(24, 37), S(44, 97), S(35,106) },   // Defended Minor
+    { S(0, 0), S( 0, 0), S( 9, 14), S( 9, 14), S( 7, 14), S(24, 48) } }, // Defended Major
+  { { S(0, 0), S( 0,32), S(33, 41), S(31, 50), S(41,100), S(35,104) },   // Weak Minor
+    { S(0, 0), S( 0,27), S(26, 57), S(26, 57), S(0 , 43), S(23, 51) } }  // Weak Major
   };
 
   // ThreatenedByPawn[PieceType] contains a penalty according to which piece
@@ -153,9 +153,9 @@ namespace {
   };
 
   // Assorted bonuses and penalties used by evaluation
-  const Score KingOnOne        = S(, 58);
-  const Score KingOnMany       = S(,125);
-  const Score RookOnPawn       = S(, 27);
+  const Score KingOnOne        = S( 2, 58);
+  const Score KingOnMany       = S( 6,125);
+  const Score RookOnPawn       = S( 7, 27);
   const Score RookOpenFile     = S(43, 21);
   const Score RookSemiOpenFile = S(19, 10);
   const Score BishopPawns      = S( 8, 12);
@@ -490,8 +490,6 @@ namespace {
   }
 
 
-
-
   // evaluate_threats() assigns bonuses according to the type of attacking piece
   // and the type of attacked one.
 
@@ -500,49 +498,50 @@ namespace {
 
     const Color Them = (Us == WHITE ? BLACK : WHITE);
 
-    enum { Protected_Minor, Protected_Major, Minor, Major };
-    Bitboard b, weakEnemies, protectedEnemies;
+    enum { Defended, Weak };
+    enum { Minor, Major };
+
+    Bitboard b, weak, defended;
     Score score = SCORE_ZERO;
 
-    // Enemies defended by a pawn and under our attack
-    protectedEnemies = (pos.pieces(Them) ^ pos.pieces(Them, PAWN))
-                       & ei.attackedBy[Them][PAWN]
-                       & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP] | ei.attackedBy[Us][ROOK]);
+    // Non-pawn enemies defended by a pawn and under our attack
+    defended =  (pos.pieces(Them) ^ pos.pieces(Them, PAWN))
+               ei.attackedBy[Them][PAWN]
+              & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP] | ei.attackedBy[Us][ROOK]);
 
-    if (protectedEnemies)
+    // Add a bonus according to the kind of attacking pieces
+    if (defended)
     {
-        // Enemies defended by a pawn and under our attack by a minor piece
-        b = protectedEnemies & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
+        b = defended & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
         while (b)
-            score += Threat[Protected_Minor][type_of(pos.piece_on(pop_lsb(&b)))];
+            score += Threat[Defended][Minor][type_of(pos.piece_on(pop_lsb(&b)))];
 
-        // Enemies defended by a pawn and under our attack by a ROOK
-        b = protectedEnemies & (ei.attackedBy[Us][ROOK]);
+        b = defended & (ei.attackedBy[Us][ROOK]);
         while (b)
-            score += Threat[Protected_Major][type_of(pos.piece_on(pop_lsb(&b)))];
+            score += Threat[Defended][Major][type_of(pos.piece_on(pop_lsb(&b)))];
     }
 
     // Enemies not defended by a pawn and under our attack
-    weakEnemies =   pos.pieces(Them)
-                 & ~ei.attackedBy[Them][PAWN]
-                 &  ei.attackedBy[Us][ALL_PIECES];
+    weak =   pos.pieces(Them)
+          & ~ei.attackedBy[Them][PAWN]
+          &  ei.attackedBy[Us][ALL_PIECES];
 
-    // Add a bonus according if the attacking pieces are minor or major
-    if (weakEnemies)
+    // Add a bonus according to the kind of attacking pieces
+    if (weak)
     {
-        b = weakEnemies & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
+        b = weak & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
         while (b)
-            score += Threat[Minor][type_of(pos.piece_on(pop_lsb(&b)))];
+            score += Threat[Weak][Minor][type_of(pos.piece_on(pop_lsb(&b)))];
 
-        b = weakEnemies & (ei.attackedBy[Us][ROOK] | ei.attackedBy[Us][QUEEN]);
+        b = weak & (ei.attackedBy[Us][ROOK] | ei.attackedBy[Us][QUEEN]);
         while (b)
-            score += Threat[Major][type_of(pos.piece_on(pop_lsb(&b)))];
+            score += Threat[Weak][Major][type_of(pos.piece_on(pop_lsb(&b)))];
 
-        b = weakEnemies & ~ei.attackedBy[Them][ALL_PIECES];
+        b = weak & ~ei.attackedBy[Them][ALL_PIECES];
         if (b)
             score += more_than_one(b) ? Hanging * popcount<Max15>(b) : Hanging;
 
-        b = weakEnemies & ei.attackedBy[Us][KING];
+        b = weak & ei.attackedBy[Us][KING];
         if (b)
             score += more_than_one(b) ? KingOnMany : KingOnOne;
     }
index 6a39e688c62e1f5f68ca6ebf648ee78fa01a9124..5f43460ac4c555982a5731e21f4bb2143b679b27 100644 (file)
@@ -331,7 +331,6 @@ namespace {
                     alpha = (alpha + beta) / 2;
                     beta = std::min(bestValue + delta, VALUE_INFINITE);
                 }
-
                 else
                     break;
 
index 62e200bdcf9d3ad70f84f39b09a61e413afe3cd9..23f6277e473446c619dacdd473ac8cfc6612eda9 100644 (file)
@@ -97,24 +97,20 @@ void TranspositionTable::store(const Key key, Value v, Bound b, Depth d, Move m,
   const uint16_t key16 = key >> 48; // Use the high 16 bits as key inside the cluster
 
   for (unsigned i = 0; i < TTClusterSize; ++i)
-  {
       if (!tte[i].key16 || tte[i].key16 == key16) // Empty or overwrite old
       {
           // Save preserving any existing ttMove
           tte[i].save(key16, v, b, d, m ? m : tte[i].move(), generation, statV);
           return;
       }
-  }
 
   // Implement replace strategy
   TTEntry* replace = tte;
   for (unsigned i = 1; i < TTClusterSize; ++i)
-  {
       if (  ((  tte[i].genBound8 & 0xFC) == generation || tte[i].bound() == BOUND_EXACT)
           - ((replace->genBound8 & 0xFC) == generation)
           - (tte[i].depth8 < replace->depth8) < 0)
           replace = &tte[i];
-  }
 
   replace->save(key16, v, b, d, m, generation, statV);
 }
index 4b7c7cec6f8fee84720eb931bbd503178ec1c420..94be83380a6cf392fe1d3dda3c3bbaf172109591 100644 (file)
@@ -427,7 +427,7 @@ inline Move make(Square from, Square to, PieceType pt = KNIGHT) {
 }
 
 inline bool is_ok(Move m) {
-  return from_sq(m) != to_sq(m); // Catches also MOVE_NULL and MOVE_NONE
+  return from_sq(m) != to_sq(m); // Catch also MOVE_NULL and MOVE_NONE
 }
 
 #endif // #ifndef TYPES_H_INCLUDED