From: Fabian Fichter Date: Sun, 19 Apr 2020 12:27:56 +0000 (+0200) Subject: Consider pins by lame leapers in slider blockers X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=6b1cfa5e197a57ecb1718922510ba5d639c727dc;p=fairystockfish.git Consider pins by lame leapers in slider blockers janggi Total: 300 W: 135 L: 126 D: 39 xiangqi Total: 300 W: 95 L: 92 D: 113 --- diff --git a/src/bitboard.h b/src/bitboard.h index 3e8f05a..e4f7e57 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -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, diff --git a/src/position.cpp b/src/position.cpp index 44d5401..228cf7a 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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))) {