Add connected bonus for shogi pawns
authorFabian Fichter <ianfab@users.noreply.github.com>
Sat, 3 Nov 2018 13:11:03 +0000 (14:11 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sat, 3 Nov 2018 13:11:03 +0000 (14:11 +0100)
shogi
ELO: 26.11 +-33.2 (95%) LOS: 93.9%
Total: 400 W: 204 L: 174 D: 22

euroshogi
ELO: 15.65 +-33.7 (95%) LOS: 81.9%
Total: 400 W: 204 L: 186 D: 10

minishogi
ELO: 0.87 +-32.8 (95%) LOS: 52.1%
Total: 400 W: 185 L: 184 D: 31

src/pawns.cpp

index 6976f4c..805c816 100644 (file)
@@ -146,7 +146,10 @@ namespace {
             score -= Doubled;
     }
 
-    const Square* pl_shogi   = pos.squares<SHOGI_PAWN>(Us);
+    const Square* pl_shogi = pos.squares<SHOGI_PAWN>(Us);
+
+    ourPawns   = pos.pieces(Us,   SHOGI_PAWN);
+    theirPawns = pos.pieces(Them, SHOGI_PAWN);
 
     // Loop through all shogi pawns of the current color and score each one
     while ((s = *pl_shogi++) != SQ_NONE)
@@ -156,6 +159,13 @@ namespace {
         File f = file_of(s);
 
         e->semiopenFiles[Us] &= ~(1 << f);
+
+        opposed    = theirPawns & forward_file_bb(Us, s);
+        neighbours = ourPawns   & adjacent_files_bb(f);
+        phalanx    = neighbours & rank_bb(s);
+
+        if (phalanx)
+            score += Connected[opposed][bool(phalanx)][0][relative_rank(Us, s, pos.max_rank())] / 2;
     }
 
     return score;