]> git.sesse.net Git - stockfish/commitdiff
Rename pawn chain to connected
authorMarco Costalba <mcostalba@gmail.com>
Wed, 1 Jan 2014 09:50:30 +0000 (10:50 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 1 Jan 2014 09:56:57 +0000 (10:56 +0100)
The flag raises also in case of a pawn duo, i.e.
when we have two adjacent pawns on the same rank,
and not only in case of a chain, i.e. when the two
pawns are on a diagonal line.

See this for a reference:
http://en.wikipedia.org/wiki/Connected_pawns

Renaming suggested by Ralph.

No functional change.

src/pawns.cpp

index 5a0e5d21e92ec864f9581d986e0f0051d5a92085..74ae4c2ff5ee78d47036d32aae73d260d0d51468 100644 (file)
@@ -49,8 +49,8 @@ namespace {
   { S(20, 28), S(29, 31), S(33, 31), S(33, 31),
     S(33, 31), S(33, 31), S(29, 31), S(20, 28) } };
 
-  // Pawn chain membership bonus by file and rank (initialized by formula)
-  Score ChainMember[FILE_NB][RANK_NB];
+  // Connected pawn bonus by file and rank (initialized by formula)
+  Score Connected[FILE_NB][RANK_NB];
 
   // Candidate passed pawn bonus by rank
   const Score CandidatePassed[RANK_NB] = {
@@ -89,7 +89,7 @@ namespace {
     Bitboard b;
     Square s;
     File f;
-    bool passed, isolated, doubled, opposed, chain, backward, candidate;
+    bool passed, isolated, doubled, opposed, connected, backward, candidate;
     Score value = SCORE_ZERO;
     const Square* pl = pos.list<PAWN>(Us);
 
@@ -113,22 +113,22 @@ namespace {
         // This file cannot be semi-open
         e->semiopenFiles[Us] &= ~(1 << f);
 
-        // Our rank plus previous one. Used for chain detection
+        // Our rank plus previous one
         b = rank_bb(s) | rank_bb(s - pawn_push(Us));
 
-        // Flag the pawn as passed, isolated, doubled or member of a pawn
-        // chain (but not the backward one).
-        chain    =   ourPawns   & adjacent_files_bb(f) & b;
-        isolated = !(ourPawns   & adjacent_files_bb(f));
-        doubled  =   ourPawns   & forward_bb(Us, s);
-        opposed  =   theirPawns & forward_bb(Us, s);
-        passed   = !(theirPawns & passed_pawn_mask(Us, s));
+        // Flag the pawn as passed, isolated, doubled or
+        // connected (but not the backward one).
+        connected =   ourPawns   & adjacent_files_bb(f) & b;
+        isolated  = !(ourPawns   & adjacent_files_bb(f));
+        doubled   =   ourPawns   & forward_bb(Us, s);
+        opposed   =   theirPawns & forward_bb(Us, s);
+        passed    = !(theirPawns & passed_pawn_mask(Us, s));
 
         // Test for backward pawn.
-        // If the pawn is passed, isolated, or member of a pawn chain it cannot
-        // be backward. If there are friendly pawns behind on adjacent files
+        // If the pawn is passed, isolated, or connected it cannot be
+        // backward. If there are friendly pawns behind on adjacent files
         // or if it can capture an enemy pawn it cannot be backward either.
-        if (   (passed | isolated | chain)
+        if (   (passed | isolated | connected)
             || (ourPawns & pawn_attack_span(Them, s))
             || (pos.attacks_from<PAWN>(s, Us) & theirPawns))
             backward = false;
@@ -172,8 +172,8 @@ namespace {
         if (backward)
             value -= Backward[opposed][f];
 
-        if (chain)
-            value += ChainMember[f][relative_rank(Us, s)];
+        if (connected)
+            value += Connected[f][relative_rank(Us, s)];
 
         if (candidate)
         {
@@ -203,14 +203,14 @@ namespace Pawns {
 
 void init() {
 
-  const int chainByFile[8] = { 1, 3, 3, 4, 4, 3, 3, 1 };
+  const int bonusesByFile[8] = { 1, 3, 3, 4, 4, 3, 3, 1 };
   int bonus;
 
   for (Rank r = RANK_1; r < RANK_8; ++r)
       for (File f = FILE_A; f <= FILE_H; ++f)
       {
-          bonus = r * (r-1) * (r-2) + chainByFile[f] * (r/2 + 1);
-          ChainMember[f][r] = make_score(bonus, bonus);
+          bonus = r * (r-1) * (r-2) + bonusesByFile[f] * (r/2 + 1);
+          Connected[f][r] = make_score(bonus, bonus);
       }
 }