From: Fabian Fichter Date: Sat, 18 Jul 2020 12:54:43 +0000 (+0200) Subject: Merge official-stockfish/master X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=fe1d75eea28eba55542c01f0b0addcda64c63a69;p=fairystockfish.git Merge official-stockfish/master bench: 5255035 --- fe1d75eea28eba55542c01f0b0addcda64c63a69 diff --cc src/movegen.cpp index a271a57,9964ad3..ab47a9b --- a/src/movegen.cpp +++ b/src/movegen.cpp @@@ -322,73 -217,22 +322,64 @@@ namespace constexpr bool Checks = Type == QUIET_CHECKS; // Reduce template instantations moveList = generate_pawn_moves(pos, moveList, target); - moveList = generate_moves(pos, moveList, Us, target); - moveList = generate_moves(pos, moveList, Us, target); - moveList = generate_moves< ROOK, Checks>(pos, moveList, Us, target); - moveList = generate_moves< QUEEN, Checks>(pos, moveList, Us, target); - - if (Type != QUIET_CHECKS && Type != EVASIONS) + for (PieceType pt : pos.piece_types()) + if (pt != PAWN && pt != KING) + moveList = generate_moves(pos, moveList, Us, pt, target); + // generate drops + if (pos.piece_drops() && Type != CAPTURES && pos.count_in_hand(Us, ALL_PIECES)) + for (PieceType pt : pos.piece_types()) + moveList = generate_drops(pos, moveList, pt, target & ~pos.pieces(~Us)); + + if (Type != QUIET_CHECKS && Type != EVASIONS && pos.count(Us)) { Square ksq = pos.square(Us); - Bitboard b = pos.attacks_from(ksq) & target; + Bitboard b = ( (pos.attacks_from(Us, KING, ksq) & pos.pieces()) + | (pos.moves_from(Us, KING, ksq) & ~pos.pieces())) & target; while (b) - *moveList++ = make_move(ksq, pop_lsb(&b)); + moveList = make_move_and_gating(pos, moveList, Us, ksq, pop_lsb(&b)); + + // Passing move by king + if (pos.pass()) + *moveList++ = make(ksq, ksq); - if (Type != CAPTURES && pos.can_castle(CastlingRights(OO | OOO))) - { - if (!pos.castling_impeded(OO) && pos.can_castle(OO)) - moveList = make_move_and_gating(pos, moveList, Us, ksq, pos.castling_rook_square(OO)); - - if (!pos.castling_impeded(OOO) && pos.can_castle(OOO)) - moveList = make_move_and_gating(pos, moveList, Us, ksq, pos.castling_rook_square(OOO)); - } + if ((Type != CAPTURES) && pos.can_castle(Us & ANY_CASTLING)) + for(CastlingRights cr : { Us & KING_SIDE, Us & QUEEN_SIDE } ) + if (!pos.castling_impeded(cr) && pos.can_castle(cr)) - *moveList++ = make(ksq, pos.castling_rook_square(cr)); ++ moveList = make_move_and_gating(pos, moveList, Us,ksq, pos.castling_rook_square(cr)); + } + // Workaround for passing: Execute a non-move with any piece + else if (pos.pass() && !pos.count(Us) && pos.pieces(Us)) + *moveList++ = make(lsb(pos.pieces(Us)), lsb(pos.pieces(Us))); + + // Castling with non-king piece - if (!pos.count(Us) && Type != CAPTURES && pos.can_castle(CastlingRights(OO | OOO))) ++ if (!pos.count(Us) && Type != CAPTURES && pos.can_castle(Us & ANY_CASTLING)) + { + Square from = make_square(FILE_E, pos.castling_rank(Us)); - if (!pos.castling_impeded(OO) && pos.can_castle(OO)) - moveList = make_move_and_gating(pos, moveList, Us, from, pos.castling_rook_square(OO)); - - if (!pos.castling_impeded(OOO) && pos.can_castle(OOO)) - moveList = make_move_and_gating(pos, moveList, Us, from, pos.castling_rook_square(OOO)); ++ for(CastlingRights cr : { Us & KING_SIDE, Us & QUEEN_SIDE } ) ++ if (!pos.castling_impeded(cr) && pos.can_castle(cr)) ++ moveList = make_move_and_gating(pos, moveList, Us, from, pos.castling_rook_square(cr)); + } + + // Special moves + if (pos.cambodian_moves() && pos.gates(Us)) + { + if (Type != CAPTURES && Type != EVASIONS && (pos.pieces(Us, KING) & pos.gates(Us))) + { + Square from = pos.square(Us); + Bitboard b = PseudoAttacks[WHITE][KNIGHT][from] & rank_bb(rank_of(from + (Us == WHITE ? NORTH : SOUTH))) + & target & ~pos.pieces(); + while (b) + moveList = make_move_and_gating(pos, moveList, Us, from, pop_lsb(&b)); + } + + Bitboard b = pos.pieces(Us, FERS) & pos.gates(Us); + while (b) + { + Square from = pop_lsb(&b); + Square to = from + 2 * (Us == WHITE ? NORTH : SOUTH); + if (is_ok(to) && (target & to)) + moveList = make_move_and_gating(pos, moveList, Us, from, to); + } } return moveList; diff --cc src/search.cpp index 0a0b60a,70520ac..a225d6f --- a/src/search.cpp +++ b/src/search.cpp @@@ -1099,13 -1023,10 +1099,12 @@@ moves_loop: // When in check, search st // Futility pruning: parent node (~5 Elo) if ( lmrDepth < 6 && !inCheck - && ss->staticEval + 235 + 172 * lmrDepth <= alpha - && (*contHist[0])[movedPiece][to_sq(move)] - + (*contHist[1])[movedPiece][to_sq(move)] - + (*contHist[3])[movedPiece][to_sq(move)] < 27400) + && !( pos.extinction_value() == -VALUE_MATE + && pos.extinction_piece_types().find(ALL_PIECES) == pos.extinction_piece_types().end()) + && ss->staticEval + (235 + 172 * lmrDepth) * (1 + pos.check_counting()) <= alpha - && thisThread->mainHistory[us][from_to(move)] - + (*contHist[0])[history_slot(movedPiece)][to_sq(move)] ++ && (*contHist[0])[history_slot(movedPiece)][to_sq(move)] + + (*contHist[1])[history_slot(movedPiece)][to_sq(move)] - + (*contHist[3])[history_slot(movedPiece)][to_sq(move)] < 25000) ++ + (*contHist[3])[history_slot(movedPiece)][to_sq(move)] < 27400) continue; // Prune moves with negative SEE (~20 Elo) @@@ -1255,18 -1169,11 +1254,11 @@@ r -= 2 + ttPv; ss->statScore = thisThread->mainHistory[us][from_to(move)] - + (*contHist[0])[movedPiece][to_sq(move)] - + (*contHist[1])[movedPiece][to_sq(move)] - + (*contHist[3])[movedPiece][to_sq(move)] + + (*contHist[0])[history_slot(movedPiece)][to_sq(move)] + + (*contHist[1])[history_slot(movedPiece)][to_sq(move)] + + (*contHist[3])[history_slot(movedPiece)][to_sq(move)] - 4926; - // Reset statScore to zero if negative and most stats shows >= 0 - if ( ss->statScore < 0 - && (*contHist[0])[history_slot(movedPiece)][to_sq(move)] >= 0 - && (*contHist[1])[history_slot(movedPiece)][to_sq(move)] >= 0 - && thisThread->mainHistory[us][from_to(move)] >= 0) - ss->statScore = 0; - // Decrease/increase reduction by comparing opponent's stat score (~10 Elo) if (ss->statScore >= -102 && (ss-1)->statScore < -114) r--;