From: Fabian Fichter Date: Fri, 14 Aug 2020 13:45:40 +0000 (+0200) Subject: Simplify handling special riders X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=36940d340b5688fcf3960e9db662f809a490cf9f;p=fairystockfish.git Simplify handling special riders No functional change. --- diff --git a/src/movegen.cpp b/src/movegen.cpp index 31d7118..bcad30c 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -333,7 +333,7 @@ namespace { break; case EVASIONS: { - if (pos.checkers() & (pos.pieces(CANNON, BANNER) | pos.pieces(HORSE, ELEPHANT) | pos.pieces(JANGGI_CANNON, JANGGI_ELEPHANT))) + if (pos.checkers() & pos.non_sliding_riders()) { target = ~pos.pieces(Us); break; @@ -490,7 +490,7 @@ ExtMove* generate(const Position& pos, ExtMove* moveList) { *moveList++ = make(ksq, ksq); // Consider all evasion moves for special pieces - if (sliders & (pos.pieces(CANNON, BANNER) | pos.pieces(HORSE, ELEPHANT) | pos.pieces(JANGGI_CANNON, JANGGI_ELEPHANT))) + if (sliders & pos.non_sliding_riders()) { Bitboard target = pos.board_bb() & ~pos.pieces(us); Bitboard b = ( (pos.attacks_from(us, KING, ksq) & pos.pieces()) diff --git a/src/position.cpp b/src/position.cpp index 8b3360f..84cd5f4 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1052,7 +1052,7 @@ bool Position::pseudo_legal(const Move m) const { // Evasions generator already takes care to avoid some kind of illegal moves // and legal() relies on this. We therefore have to take care that the same // kind of moves are filtered out here. - if (checkers() && !(checkers() & (pieces(CANNON, BANNER) | pieces(HORSE, ELEPHANT) | pieces(JANGGI_CANNON, JANGGI_ELEPHANT)))) + if (checkers() && !(checkers() & non_sliding_riders())) { if (type_of(pc) != KING) { diff --git a/src/position.h b/src/position.h index 285773b..eae5c66 100644 --- a/src/position.h +++ b/src/position.h @@ -181,6 +181,7 @@ public: Bitboard pieces(Color c, PieceType pt) const; Bitboard pieces(Color c, PieceType pt1, PieceType pt2) const; Bitboard major_pieces(Color c) const; + Bitboard non_sliding_riders() const; Piece piece_on(Square s) const; Piece unpromoted_piece_on(Square s) const; Square ep_square() const; @@ -833,6 +834,10 @@ inline Bitboard Position::major_pieces(Color c) const { return pieces(c) & (pieces(QUEEN) | pieces(AIWOK) | pieces(ARCHBISHOP) | pieces(CHANCELLOR) | pieces(AMAZON)); } +inline Bitboard Position::non_sliding_riders() const { + return pieces(CANNON, BANNER) | pieces(HORSE, ELEPHANT) | pieces(JANGGI_CANNON, JANGGI_ELEPHANT); +} + inline int Position::count(Color c, PieceType pt) const { return pieceCount[make_piece(c, pt)]; }