X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=7ff9aaa466902ae5b851ea2c225a853d8416c576;hp=238631fabaef6bb4d0f621ed21203f906358aed4;hb=05c6f7a40b62f286873945f937c2ef3cae183e41;hpb=148490f04cbd21afd9b01431ee7c947ac0bf78a8 diff --git a/src/search.cpp b/src/search.cpp index 238631fa..7ff9aaa4 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -163,11 +163,11 @@ size_t Search::perft(Position& pos, Depth depth) { size_t cnt = 0; CheckInfo ci(pos); - for (MoveList ml(pos); !ml.end(); ++ml) + for (MoveList it(pos); *it; ++it) { - pos.do_move(ml.move(), st, ci, pos.move_gives_check(ml.move(), ci)); + pos.do_move(*it, st, ci, pos.move_gives_check(*it, ci)); cnt += perft(pos, depth - ONE_PLY); - pos.undo_move(ml.move()); + pos.undo_move(*it); } return cnt; @@ -416,8 +416,12 @@ namespace { if (Options["Use Search Log"]) { + RootMove& rm = RootMoves[0]; + if (skill.best != MOVE_NONE) + rm = *std::find(RootMoves.begin(), RootMoves.end(), skill.best); + Log log(Options["Search Log Filename"]); - log << pretty_pv(pos, depth, bestValue, Time::now() - SearchTime, &RootMoves[0].pv[0]) + log << pretty_pv(pos, depth, rm.score, Time::now() - SearchTime, rm.pv.data()) << std::endl; } @@ -766,7 +770,11 @@ namespace { split_point_start: // At split points actual search starts from here - MovePicker mp(pos, ttMove, depth, History, Countermoves, ss, PvNode ? -VALUE_INFINITE : beta); + Square prevMoveSq = to_sq((ss-1)->currentMove); + Move countermoves[] = { Countermoves[pos.piece_on(prevMoveSq)][prevMoveSq].first, + Countermoves[pos.piece_on(prevMoveSq)][prevMoveSq].second }; + + MovePicker mp(pos, ttMove, depth, History, countermoves, ss, PvNode ? -VALUE_INFINITE : beta); CheckInfo ci(pos); value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc singularExtensionNode = !RootNode @@ -942,6 +950,9 @@ split_point_start: // At split points actual search starts from here && move != ss->killers[1]) { ss->reduction = reduction(depth, moveCount); + if (move == countermoves[0] || move == countermoves[1]) + ss->reduction = std::max(DEPTH_ZERO, ss->reduction-ONE_PLY); + Depth d = std::max(newDepth - ss->reduction, ONE_PLY); if (SpNode) alpha = splitPoint->alpha; @@ -1093,10 +1104,7 @@ split_point_start: // At split points actual search starts from here Value bonus = Value(int(depth) * int(depth)); History.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus); if (is_ok((ss-1)->currentMove)) - { - Square prevSq = to_sq((ss-1)->currentMove); - Countermoves.update(pos.piece_on(prevSq), prevSq, bestMove); - } + Countermoves.update(pos.piece_on(prevMoveSq), prevMoveSq, bestMove); // Decrease history of all the other played non-capture moves for (int i = 0; i < playedMoveCount - 1; i++) @@ -1247,7 +1255,6 @@ split_point_start: // At split points actual search starts from here // Prune moves with negative or equal SEE and also moves with positive // SEE where capturing piece loses a tempo and SEE < beta - futilityBase. if ( futilityBase < beta - && depth < DEPTH_ZERO && pos.see(move, beta - futilityBase) <= 0) { bestValue = std::max(bestValue, futilityBase);