Consider pins by lame leapers in slider blockers
authorFabian Fichter <ianfab@users.noreply.github.com>
Sun, 19 Apr 2020 12:27:56 +0000 (14:27 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sun, 19 Apr 2020 12:27:56 +0000 (14:27 +0200)
janggi
Total: 300 W: 135 L: 126 D: 39

xiangqi
Total: 300 W: 95 L: 92 D: 113

src/bitboard.h
src/position.cpp

index 3e8f05a..e4f7e57 100644 (file)
@@ -279,6 +279,16 @@ inline Bitboard between_bb(Square s1, Square s2) {
                            ^(AllSquares << (s2 + !(s1 < s2))));
 }
 
+inline Bitboard between_bb(Square s1, Square s2, PieceType pt) {
+  if (pt == HORSE)
+      return PseudoAttacks[WHITE][WAZIR][s2] & PseudoAttacks[WHITE][FERS][s1];
+  else if (pt == JANGGI_ELEPHANT)
+      return  (PseudoAttacks[WHITE][WAZIR][s2] & PseudoAttacks[WHITE][ALFIL][s1])
+            | (PseudoAttacks[WHITE][KNIGHT][s2] & PseudoAttacks[WHITE][FERS][s1]);
+  else
+      return between_bb(s1, s2);
+}
+
 
 /// forward_ranks_bb() returns a bitboard representing the squares on the ranks
 /// in front of the given one, from the point of view of the given color. For instance,
index 44d5401..228cf7a 100644 (file)
@@ -718,14 +718,28 @@ Bitboard Position::slider_blockers(Bitboard sliders, Square s, Bitboard& pinners
   {
       Bitboard b = sliders & (PseudoAttacks[~c][pt][s] ^ LeaperAttacks[~c][pt][s]) & pieces(c, pt);
       if (b)
-          snipers |= b & ~attacks_bb(~c, pt, s, pieces());
+      {
+          // Consider asymmetrical moves (e.g., horse)
+          if (AttackRiderTypes[pt] & ASYMMETRICAL_RIDERS)
+          {
+              Bitboard asymmetricals = PseudoAttacks[~c][pt][s] & pieces(c, pt);
+              while (asymmetricals)
+              {
+                  Square s2 = pop_lsb(&asymmetricals);
+                  if (!(attacks_from(c, pt, s2) & s))
+                      snipers |= s2;
+              }
+          }
+          else
+              snipers |= b & ~attacks_bb(~c, pt, s, pieces());
+      }
   }
   Bitboard occupancy = pieces() ^ snipers;
 
   while (snipers)
   {
     Square sniperSq = pop_lsb(&snipers);
-    Bitboard b = between_bb(s, sniperSq) & occupancy;
+    Bitboard b = between_bb(s, sniperSq, type_of(piece_on(sniperSq))) & occupancy;
 
     if (b && (!more_than_one(b) || ((AttackRiderTypes[type_of(piece_on(sniperSq))] & HOPPING_RIDERS) && popcount(b) == 2)))
     {