diff --git a/src/bitboard.h b/src/bitboard.h index d028be02906..cdff4c759bc 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -163,7 +163,6 @@ inline Bitboard pawn_attacks_bb(Color c, Square s) { inline Bitboard line_bb(Square s1, Square s2) { assert(is_ok(s1) && is_ok(s2)); - return LineBB[s1][s2]; } @@ -178,7 +177,6 @@ inline Bitboard line_bb(Square s1, Square s2) { inline Bitboard between_bb(Square s1, Square s2) { assert(is_ok(s1) && is_ok(s2)); - return BetweenBB[s1][s2]; } @@ -216,7 +214,6 @@ template inline Bitboard attacks_bb(Square s) { assert((Pt != PAWN) && (is_ok(s))); - return PseudoAttacks[Pt][s]; } diff --git a/src/evaluate.cpp b/src/evaluate.cpp index c8656fc2eac..da0867660af 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -219,7 +219,7 @@ Value Eval::evaluate(const Position& pos, int optimism) { v = v * (200 - shuffling) / 214; // Guarantee evaluation does not hit the tablebase range - v = std::clamp(int(v), VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1); + v = std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1); return v; } diff --git a/src/position.h b/src/position.h index 7ce3556f0e9..154ed652942 100644 --- a/src/position.h +++ b/src/position.h @@ -252,13 +252,11 @@ inline CastlingRights Position::castling_rights(Color c) const { inline bool Position::castling_impeded(CastlingRights cr) const { assert(cr == WHITE_OO || cr == WHITE_OOO || cr == BLACK_OO || cr == BLACK_OOO); - return pieces() & castlingPath[cr]; } inline Square Position::castling_rook_square(CastlingRights cr) const { assert(cr == WHITE_OO || cr == WHITE_OOO || cr == BLACK_OO || cr == BLACK_OOO); - return castlingRookSquare[cr]; } diff --git a/src/search.cpp b/src/search.cpp index 550d20adfd7..e43411bc57d 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -67,7 +67,7 @@ constexpr int futility_move_count(bool improving, Depth depth) { Value to_corrected_static_eval(Value v, const Worker& w, const Position& pos) { auto cv = w.correctionHistory[pos.side_to_move()][pawn_structure_index(pos)]; v += cv * std::abs(cv) / 12890; - return std::clamp(int(v), VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1); + return std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1); } // History and stats update bonus, based on depth @@ -297,9 +297,9 @@ void Search::Worker::iterative_deepening() { // Reset aspiration window starting size Value avg = rootMoves[pvIdx].averageScore; - delta = Value(9) + int(avg) * avg / 12480; + delta = 9 + avg * avg / 12480; alpha = std::max(avg - delta, -VALUE_INFINITE); - beta = std::min(avg + delta, int(VALUE_INFINITE)); + beta = std::min(avg + delta, VALUE_INFINITE); // Adjust optimism based on root move's averageScore (~4 Elo) optimism[us] = 131 * avg / (std::abs(avg) + 95); @@ -350,7 +350,7 @@ void Search::Worker::iterative_deepening() { } else if (bestValue >= beta) { - beta = std::min(bestValue + delta, int(VALUE_INFINITE)); + beta = std::min(bestValue + delta, VALUE_INFINITE); ++failedHighCnt; } else @@ -481,7 +481,6 @@ void Search::Worker::clear() { for (auto& h : to) h->fill(-71); - for (size_t i = 1; i < reductions.size(); ++i) reductions[i] = int((20.37 + std::log(size_t(options["Threads"])) / 2) * std::log(i)); } @@ -538,7 +537,7 @@ Value Search::Worker::search( // Check for the available remaining time if (is_mainthread()) - main_manager()->check_time(*this); + main_manager()->check_time(*thisThread); // Used to send selDepth info to GUI (selDepth counts from 1, ply from 0) if (PvNode && thisThread->selDepth < ss->ply + 1) @@ -680,10 +679,8 @@ Value Search::Worker::search( } } - - Value unadjustedStaticEval = VALUE_NONE; - // Step 6. Static evaluation of the position + Value unadjustedStaticEval = VALUE_NONE; if (ss->inCheck) { // Skip early pruning when in check @@ -820,11 +817,10 @@ Value Search::Worker::search( if (cutNode && depth >= 8 && !ttMove) depth -= 2; - probCutBeta = beta + 182 - 68 * improving; - // Step 11. ProbCut (~10 Elo) // If we have a good enough capture (or queen promotion) and a reduced search returns a value // much above beta, we can (almost) safely prune the previous move. + probCutBeta = beta + 182 - 68 * improving; if ( !PvNode && depth > 3 && std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY @@ -1285,7 +1281,6 @@ Value Search::Worker::search( { if (capture) capturesSearched[captureCount++] = move; - else quietsSearched[quietCount++] = move; } @@ -1424,9 +1419,8 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta, && (tte->bound() & (ttValue >= beta ? BOUND_LOWER : BOUND_UPPER))) return ttValue; - Value unadjustedStaticEval = VALUE_NONE; - // Step 4. Static evaluation of the position + Value unadjustedStaticEval = VALUE_NONE; if (ss->inCheck) bestValue = futilityBase = -VALUE_INFINITE; else @@ -1597,7 +1591,6 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta, if (ss->inCheck && bestValue == -VALUE_INFINITE) { assert(!MoveList(pos).size()); - return mated_in(ss->ply); // Plies to mate from the root } @@ -1617,8 +1610,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth Search::Worker::reduction(bool i, Depth d, int mn, int delta) { int reductionScale = reductions[d] * reductions[mn]; - return (reductionScale + 1177 - int(delta) * 776 / int(rootDelta)) / 1024 - + (!i && reductionScale > 842); + return (reductionScale + 1177 - delta * 776 / rootDelta) / 1024 + (!i && reductionScale > 842); } namespace { @@ -1628,7 +1620,6 @@ namespace { Value value_to_tt(Value v, int ply) { assert(v != VALUE_NONE); - return v >= VALUE_TB_WIN_IN_MAX_PLY ? v + ply : v <= VALUE_TB_LOSS_IN_MAX_PLY ? v - ply : v; } @@ -1810,9 +1801,9 @@ Move Skill::pick_best(const RootMoves& rootMoves, size_t multiPV) { for (size_t i = 0; i < multiPV; ++i) { // This is our magic formula - int push = int((weakness * int(topScore - rootMoves[i].score) - + delta * (rng.rand() % int(weakness))) - / 128); + int push = (weakness * int(topScore - rootMoves[i].score) + + delta * (rng.rand() % int(weakness))) + / 128; if (rootMoves[i].score + push >= maxScore) { @@ -1926,7 +1917,6 @@ bool RootMove::extract_ponder_from_tt(const TranspositionTable& tt, Position& po bool ttHit; assert(pv.size() == 1); - if (pv[0] == Move::none()) return false;