From: Fabian Fichter Date: Sat, 22 May 2021 12:21:58 +0000 (+0200) Subject: Merge official-stockfish/master X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=bd354c53d73c906fd469ab5c754f99e1e9caf28e;p=fairystockfish.git Merge official-stockfish/master bench: 5199018 --- bd354c53d73c906fd469ab5c754f99e1e9caf28e diff --cc src/movegen.cpp index 1694244,5dbc37c..4b1061b --- a/src/movegen.cpp +++ b/src/movegen.cpp @@@ -120,9 -61,9 +120,9 @@@ namespace Bitboard emptySquares; Bitboard pawnsOn7 = pos.pieces(Us, PAWN) & TRank7BB; - Bitboard pawnsNotOn7 = pos.pieces(Us, PAWN) & ~TRank7BB; + Bitboard pawnsNotOn7 = pos.pieces(Us, PAWN) & (pos.mandatory_pawn_promotion() ? ~TRank7BB : AllSquares); - Bitboard enemies = (Type == EVASIONS ? pos.pieces(Them) & target: + Bitboard enemies = (Type == EVASIONS ? pos.checkers(): Type == CAPTURES ? target : pos.pieces(Them)); // Single and double pawn pushes, no promotions @@@ -276,56 -185,12 +276,51 @@@ while (bb) { Square from = pop_lsb(&bb); - Bitboard b = attacks_bb(from, pos.pieces()) & target; - if constexpr (Checks) - b &= pos.check_squares(Pt); + Bitboard b1 = ( (pos.attacks_from(us, Pt, from) & pos.pieces()) + | (pos.moves_from(us, Pt, from) & ~pos.pieces())) & target; + PieceType promPt = pos.promoted_piece_type(Pt); + Bitboard b2 = promPt && (!pos.promotion_limit(promPt) || pos.promotion_limit(promPt) > pos.count(us, promPt)) ? b1 : Bitboard(0); + Bitboard b3 = pos.piece_demotion() && pos.is_promoted(from) ? b1 : Bitboard(0); - while (b) - *moveList++ = make_move(from, pop_lsb(&b)); + if (Checks) + { - b1 &= checkSquares; ++ b1 &= pos.check_squares(Pt); + if (b2) + b2 &= pos.check_squares(pos.promoted_piece_type(Pt)); + if (b3) + b3 &= pos.check_squares(type_of(pos.unpromoted_piece_on(from))); + } + + // Restrict target squares considering promotion zone + if (b2 | b3) + { + Bitboard promotion_zone = zone_bb(us, pos.promotion_rank(), pos.max_rank()); + if (pos.mandatory_piece_promotion()) + b1 &= (promotion_zone & from ? Bitboard(0) : ~promotion_zone) | (pos.piece_promotion_on_capture() ? ~pos.pieces() : Bitboard(0)); + // Exclude quiet promotions/demotions + if (pos.piece_promotion_on_capture()) + { + b2 &= pos.pieces(); + b3 &= pos.pieces(); + } + // Consider promotions/demotions into promotion zone + if (!(promotion_zone & from)) + { + b2 &= promotion_zone; + b3 &= promotion_zone; + } + } + + while (b1) + moveList = make_move_and_gating(pos, moveList, us, from, pop_lsb(&b1)); + + // Shogi-style piece promotions + while (b2) + *moveList++ = make(from, pop_lsb(&b2)); + + // Piece demotions + while (b3) + *moveList++ = make(from, pop_lsb(&b3)); } return moveList; diff --cc src/search.cpp index 8d52294,af7f801..13c087d --- a/src/search.cpp +++ b/src/search.cpp @@@ -1723,18 -1575,13 +1723,16 @@@ moves_loop: // When in check, search st moveCount++; - // Futility pruning + // Futility pruning and moveCount pruning if ( bestValue > VALUE_TB_LOSS_IN_MAX_PLY && !givesCheck + && !( pos.extinction_value() == -VALUE_MATE + && pos.piece_on(to_sq(move)) + && pos.extinction_piece_types().find(type_of(pos.piece_on(to_sq(move)))) != pos.extinction_piece_types().end()) && futilityBase > -VALUE_KNOWN_WIN - && !pos.advanced_pawn_push(move)) + && type_of(move) != PROMOTION) { - assert(type_of(move) != EN_PASSANT); // Due to !pos.advanced_pawn_push - // moveCount pruning if (moveCount > 2) continue;