From: Fabian Fichter Date: Sat, 25 Jan 2020 11:05:49 +0000 (+0100) Subject: Generalize check for fairy riders X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=5869689a9d65937dc1a764c86e5e138fce60d35b;p=fairystockfish.git Generalize check for fairy riders No functional change. --- diff --git a/src/position.cpp b/src/position.cpp index 9d4575d..cd392af 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -775,7 +775,7 @@ Bitboard Position::attackers_to(Square s, Bitboard occupied, Color c) const { { PieceType move_pt = pt == KING ? king_type() : pt; // Consider asymmetrical move of horse - if (move_pt == HORSE || move_pt == BANNER) + if (AttackRiderTypes[move_pt] & ASYMMETRICAL_RIDERS) { Bitboard horses = PseudoAttacks[~c][move_pt][s] & pieces(c, pt); while (horses) @@ -1060,7 +1060,7 @@ bool Position::gives_check(Move m) const { if (type_of(m) != PROMOTION && type_of(m) != PIECE_PROMOTION && type_of(m) != PIECE_DEMOTION) { PieceType pt = type_of(moved_piece(m)); - if (pt == CANNON || pt == BANNER || pt == HORSE) + if (AttackRiderTypes[pt] & (HOPPING_RIDERS | ASYMMETRICAL_RIDERS)) { if (attacks_bb(sideToMove, pt, to, (pieces() ^ from) | to) & square(~sideToMove)) return true; diff --git a/src/types.h b/src/types.h index 2ec3128..c678dd1 100644 --- a/src/types.h +++ b/src/types.h @@ -382,6 +382,8 @@ enum RiderType { RIDER_CANNON_V = 1 << 4, RIDER_HORSE = 1 << 5, RIDER_ELEPHANT = 1 << 6, + HOPPING_RIDERS = RIDER_CANNON_H | RIDER_CANNON_V, + ASYMMETRICAL_RIDERS = RIDER_HORSE, }; extern Value PieceValue[PHASE_NB][PIECE_NB];