X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=f7ddfa0481f2f32697400015c408b91bdf75abc0;hp=3cd54b00fd0e8889556dbc0f867feb3d170d572d;hb=30075e4abcf0430cef78ae0b7823390013e75618;hpb=dd884b65b7d926c7a8b01c372ca026bef3fc84a8 diff --git a/src/search.cpp b/src/search.cpp index 3cd54b00..f7ddfa04 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -284,7 +284,7 @@ namespace { bool connected_moves(const Position& pos, Move m1, Move m2); bool value_is_mate(Value value); bool move_is_killer(Move m, const SearchStack& ss); - Depth extension(const Position& pos, Move m, Depth depth, bool pvNode, bool capture, bool check, bool singleReply, bool mateThreat, bool* dangerous); + Depth extension(const Position& pos, Move m, bool pvNode, bool capture, bool check, bool singleReply, bool mateThreat, bool* dangerous); bool ok_to_do_nullmove(const Position& pos); bool ok_to_prune(const Position& pos, Move m, Move threat, Depth d); bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply); @@ -900,7 +900,7 @@ namespace { // Decide search depth for this move bool captureOrPromotion = pos.move_is_capture_or_promotion(move); bool dangerous; - ext = extension(pos, move, Depth(100), true, captureOrPromotion, pos.move_is_check(move), false, false, &dangerous); + ext = extension(pos, move, true, captureOrPromotion, pos.move_is_check(move), false, false, &dangerous); newDepth = (Iteration - 2) * OnePly + ext + InitialDepth; // Make the move, and search it @@ -1103,11 +1103,8 @@ namespace { tte = TT.retrieve(pos.get_key()); ttMove = (tte ? tte->move() : MOVE_NONE); - // Go with internal iterative deepening if we don't have a TT move or - // if search depth is more then 4*OnePly higher then TT move depth. - if ( UseIIDAtPVNodes - && depth >= 5*OnePly - &&(!ttMove || depth > tte->depth() + 4*OnePly)) + // Go with internal iterative deepening if we don't have a TT move + if (UseIIDAtPVNodes && ttMove == MOVE_NONE && depth >= 5*OnePly) { search_pv(pos, ss, alpha, beta, depth-2*OnePly, ply, threadID); ttMove = ss[ply].pv[ply]; @@ -1117,7 +1114,8 @@ namespace { // to search all moves isCheck = pos.is_check(); mateThreat = pos.has_mate_threat(opposite_color(pos.side_to_move())); - dcCandidates = pos.discovered_check_candidates(pos.side_to_move()); + CheckInfo ci(pos); + dcCandidates = ci.dc; MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]); // Loop through all legal moves until no moves remain or a beta cutoff @@ -1135,7 +1133,7 @@ namespace { movesSearched[moveCount++] = ss[ply].currentMove = move; // Decide the new search depth - ext = extension(pos, move, depth, true, captureOrPromotion, moveIsCheck, singleReply, mateThreat, &dangerous); + ext = extension(pos, move, true, captureOrPromotion, moveIsCheck, singleReply, mateThreat, &dangerous); newDepth = depth - OnePly + ext; // Make and search the move @@ -1374,7 +1372,8 @@ namespace { // Initialize a MovePicker object for the current position, and prepare // to search all moves. MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]); - dcCandidates = pos.discovered_check_candidates(pos.side_to_move()); + CheckInfo ci(pos); + dcCandidates = ci.dc; futilityValue = VALUE_NONE; useFutilityPruning = depth < SelectiveDepth && !isCheck; @@ -1397,7 +1396,7 @@ namespace { movesSearched[moveCount++] = ss[ply].currentMove = move; // Decide the new search depth - ext = extension(pos, move, depth, false, captureOrPromotion, moveIsCheck, singleReply, mateThreat, &dangerous); + ext = extension(pos, move, false, captureOrPromotion, moveIsCheck, singleReply, mateThreat, &dangerous); newDepth = depth - OnePly + ext; // Futility pruning @@ -1595,7 +1594,8 @@ namespace { // to search the moves. Because the depth is <= 0 here, only captures, // queen promotions and checks (only if depth == 0) will be generated. MovePicker mp = MovePicker(pos, ttMove, depth, H); - dcCandidates = pos.discovered_check_candidates(pos.side_to_move()); + CheckInfo ci(pos); + dcCandidates = ci.dc; enoughMaterial = pos.non_pawn_material(pos.side_to_move()) > RookValueMidgame; // Loop through the moves until no moves remain or a beta cutoff @@ -1725,7 +1725,7 @@ namespace { // Decide the new search depth. bool dangerous; - Depth ext = extension(pos, move, sp->depth, false, captureOrPromotion, moveIsCheck, false, false, &dangerous); + Depth ext = extension(pos, move, false, captureOrPromotion, moveIsCheck, false, false, &dangerous); Depth newDepth = sp->depth - OnePly + ext; // Prune? @@ -1865,7 +1865,7 @@ namespace { // Decide the new search depth. bool dangerous; - Depth ext = extension(pos, move, sp->depth, true, captureOrPromotion, moveIsCheck, false, false, &dangerous); + Depth ext = extension(pos, move, true, captureOrPromotion, moveIsCheck, false, false, &dangerous); Depth newDepth = sp->depth - OnePly + ext; // Make and search the move. @@ -2301,7 +2301,7 @@ namespace { // extended, as example because the corresponding UCI option is set to zero, // the move is marked as 'dangerous' so, at least, we avoid to prune it. - Depth extension(const Position& pos, Move m, Depth depth, bool pvNode, bool captureOrPromotion, + Depth extension(const Position& pos, Move m, bool pvNode, bool captureOrPromotion, bool check, bool singleReply, bool mateThreat, bool* dangerous) { assert(m != MOVE_NONE); @@ -2321,19 +2321,6 @@ namespace { result += MateThreatExtension[pvNode]; } - if ( pvNode - && captureOrPromotion - && pos.type_of_piece_on(move_to(m)) != PAWN - && pos.see_sign(m) >= 0) - { - result += OnePly/2; - *dangerous = true; - } - - // Do not extend at low depths - if (!pvNode && depth < 4*OnePly) - return Min(result, OnePly); // Further test with Min(result, OnePly / 2) - if (pos.type_of_piece_on(move_from(m)) == PAWN) { Color c = pos.side_to_move(); @@ -2360,6 +2347,15 @@ namespace { *dangerous = true; } + if ( pvNode + && captureOrPromotion + && pos.type_of_piece_on(move_to(m)) != PAWN + && pos.see_sign(m) >= 0) + { + result += OnePly/2; + *dangerous = true; + } + return Min(result, OnePly); }