&& !Skill(Options["Skill Level"]).enabled()
&& rootMoves[0].pv[0] != MOVE_NONE)
{
- std::map<Move, int> votes;
+ std::map<Move, int64_t> votes;
Value minScore = this->rootMoves[0].score;
// Find out minimum score and reset votes for moves which can be voted
}
// Vote according to score and depth
+ auto square = [](int64_t x) { return x * x; };
for (Thread* th : Threads)
- votes[th->rootMoves[0].pv[0]] += int(th->rootMoves[0].score - minScore)
- + int(th->completedDepth);
+ votes[th->rootMoves[0].pv[0]] += 200 + (square(th->rootMoves[0].score - minScore + 1)
+ * int64_t(th->completedDepth));
// Select best thread
- int bestVote = votes[this->rootMoves[0].pv[0]];
+ int64_t bestVote = votes[this->rootMoves[0].pv[0]];
for (Thread* th : Threads)
{
if (votes[th->rootMoves[0].pv[0]] > bestVote)
void Thread::search() {
Stack stack[MAX_PLY+7], *ss = stack+4; // To reference from (ss-4) to (ss+2)
+ Move pv[MAX_PLY+1];
Value bestValue, alpha, beta, delta;
Move lastBestMove = MOVE_NONE;
Depth lastBestMoveDepth = DEPTH_ZERO;
std::memset(ss-4, 0, 7 * sizeof(Stack));
for (int i = 4; i > 0; i--)
(ss-i)->continuationHistory = &this->continuationHistory[NO_PIECE][0]; // Use as sentinel
+ ss->pv = pv;
bestValue = delta = alpha = -VALUE_INFINITE;
beta = VALUE_INFINITE;
}
// Step 7. Razoring (~2 Elo)
- if ( depth < 2 * ONE_PLY
- && eval <= alpha - RazorMargin)
+ if ( !rootNode // The required rootNode PV handling is not available in qsearch
+ && depth < 2 * ONE_PLY
+ && eval <= alpha - RazorMargin)
return qsearch<NT>(pos, ss, alpha, beta);
improving = ss->staticEval >= (ss-2)->staticEval
|| (ss-2)->staticEval == VALUE_NONE;
// Step 8. Futility pruning: child node (~30 Elo)
- if ( !rootNode
+ if ( !PvNode
&& depth < 7 * ONE_PLY
&& eval - futility_margin(depth, improving) >= beta
&& eval < VALUE_KNOWN_WIN) // Do not return unproven wins
{
if ( !captureOrPromotion
&& !givesCheck
- && (!pos.advanced_pawn_push(move) || pos.non_pawn_material() >= Value(5000)))
+ && !pos.advanced_pawn_push(move))
{
// Move count based pruning (~30 Elo)
if (moveCountPruning)