X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=b57d040069cc2d9fbb7f1cae81f1174d5dca0c04;hp=0f5e6907b5f173de954483812068d4d6b70f08ca;hb=0fb5d7a73792146d5e8422c993473f3deab18903;hpb=a6d13428f644d2ca475a190295f9528c92bdaaec diff --git a/src/search.cpp b/src/search.cpp index 0f5e6907..b57d0400 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -368,9 +368,7 @@ void SearchStack::init() { // SearchStack::initKillers() initializes killers for a search stack entry void SearchStack::initKillers() { - mateKiller = MOVE_NONE; - for (int i = 0; i < KILLER_MAX; i++) - killers[i] = MOVE_NONE; + killers[0] = killers[1] = mateKiller = MOVE_NONE; } @@ -762,7 +760,9 @@ namespace { beta = *betaPtr; isCheck = pos.is_check(); - // Step 1. Initialize node and poll (omitted at root, init_ss_array() has already initialized root node) + // Step 1. Initialize node (polling is omitted at root) + ss->init(); + // Step 2. Check for aborted search (omitted at root) // Step 3. Mate distance pruning (omitted at root) // Step 4. Transposition table lookup (omitted at root) @@ -1108,7 +1108,7 @@ namespace { && !pos.has_pawn_on_7th(pos.side_to_move())) { // Pass ss->eval to qsearch() and avoid an evaluate call - if (!tte || tte->static_value() == VALUE_NONE) + if (!tte) TT.store(posKey, ss->eval, VALUE_TYPE_EXACT, Depth(-127*OnePly), MOVE_NONE, ss->eval, ei.kingDanger[pos.side_to_move()]); Value rbeta = beta - razor_margin(depth); @@ -1872,10 +1872,8 @@ namespace { bool move_is_killer(Move m, SearchStack* ss) { - const Move* k = ss->killers; - for (int i = 0; i < KILLER_MAX; i++, k++) - if (*k == m) - return true; + if (ss->killers[0] == m || ss->killers[1] == m) + return true; return false; } @@ -2052,9 +2050,7 @@ namespace { if (m == ss->killers[0]) return; - for (int i = KILLER_MAX - 1; i > 0; i--) - ss->killers[i] = ss->killers[i - 1]; - + ss->killers[1] = ss->killers[0]; ss->killers[0] = m; } @@ -2214,10 +2210,7 @@ namespace { ss->reduction = Depth(0); if (i < 3) - { - ss->init(); ss->initKillers(); - } } } @@ -2737,6 +2730,11 @@ namespace { StateInfo st; bool includeAllMoves = (searchMoves[0] == MOVE_NONE); + // Initialize search stack + init_ss_array(ss, PLY_MAX_PLUS_2); + ss[0].init(); + ss[0].eval = VALUE_NONE; + // Generate all legal moves MoveStack* last = generate_moves(pos, mlist); @@ -2752,10 +2750,8 @@ namespace { continue; // Find a quick score for the move - init_ss_array(ss, PLY_MAX_PLUS_2); - ss[0].eval = VALUE_NONE; - ss[0].currentMove = cur->move; pos.do_move(cur->move, st); + ss[0].currentMove = cur->move; moves[count].move = cur->move; moves[count].score = -qsearch(pos, ss+1, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 1); moves[count].pv[0] = cur->move;