mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Assorted trivial cleanups
Renaming doubleExtensions variable to multiExtensions, since now we have also triple extensions. Some extra cleanups. Recent tests used to measure the elo worth: https://tests.stockfishchess.org/tests/view/659fd0c379aa8af82b96abc3 https://tests.stockfishchess.org/tests/view/65a8f3da79aa8af82b9751e3 https://tests.stockfishchess.org/tests/view/65b51824c865510db0272740 https://tests.stockfishchess.org/tests/view/65b58fbfc865510db0272f5b closes https://github.com/official-stockfish/Stockfish/pull/5032 No functional change
This commit is contained in:
parent
ededadcd6f
commit
59691d46a1
3 changed files with 16 additions and 19 deletions
|
@ -281,7 +281,7 @@ class FeatureTransformer {
|
||||||
reinterpret_cast<const vec_t*>(&(accumulation[perspectives[p]][HalfDimensions / 2]));
|
reinterpret_cast<const vec_t*>(&(accumulation[perspectives[p]][HalfDimensions / 2]));
|
||||||
vec_t* out = reinterpret_cast<vec_t*>(output + offset);
|
vec_t* out = reinterpret_cast<vec_t*>(output + offset);
|
||||||
|
|
||||||
for (IndexType j = 0; j < NumOutputChunks; j += 1)
|
for (IndexType j = 0; j < NumOutputChunks; ++j)
|
||||||
{
|
{
|
||||||
const vec_t sum0a = vec_max_16(vec_min_16(in0[j * 2 + 0], One), Zero);
|
const vec_t sum0a = vec_max_16(vec_min_16(in0[j * 2 + 0], One), Zero);
|
||||||
const vec_t sum0b = vec_max_16(vec_min_16(in0[j * 2 + 1], One), Zero);
|
const vec_t sum0b = vec_max_16(vec_min_16(in0[j * 2 + 1], One), Zero);
|
||||||
|
@ -676,10 +676,8 @@ class FeatureTransformer {
|
||||||
update_accumulator_incremental<Perspective, 2>(pos, oldest_st, states_to_update);
|
update_accumulator_incremental<Perspective, 2>(pos, oldest_st, states_to_update);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
update_accumulator_refresh<Perspective>(pos);
|
update_accumulator_refresh<Perspective>(pos);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
template<Color Perspective>
|
template<Color Perspective>
|
||||||
void update_accumulator(const Position& pos) const {
|
void update_accumulator(const Position& pos) const {
|
||||||
|
|
|
@ -571,7 +571,7 @@ Value Search::Worker::search(
|
||||||
(ss + 1)->excludedMove = bestMove = Move::none();
|
(ss + 1)->excludedMove = bestMove = Move::none();
|
||||||
(ss + 2)->killers[0] = (ss + 2)->killers[1] = Move::none();
|
(ss + 2)->killers[0] = (ss + 2)->killers[1] = Move::none();
|
||||||
(ss + 2)->cutoffCnt = 0;
|
(ss + 2)->cutoffCnt = 0;
|
||||||
ss->doubleExtensions = (ss - 1)->doubleExtensions;
|
ss->multipleExtensions = (ss - 1)->multipleExtensions;
|
||||||
Square prevSq = ((ss - 1)->currentMove).is_ok() ? ((ss - 1)->currentMove).to_sq() : SQ_NONE;
|
Square prevSq = ((ss - 1)->currentMove).is_ok() ? ((ss - 1)->currentMove).to_sq() : SQ_NONE;
|
||||||
ss->statScore = 0;
|
ss->statScore = 0;
|
||||||
|
|
||||||
|
@ -1036,8 +1036,8 @@ moves_loop: // When in check, search starts here
|
||||||
{
|
{
|
||||||
extension = 1;
|
extension = 1;
|
||||||
|
|
||||||
// Avoid search explosion by limiting the number of double extensions
|
// We make sure to limit the extensions in some way to avoid a search explosion
|
||||||
if (!PvNode && ss->doubleExtensions <= 16)
|
if (!PvNode && ss->multipleExtensions <= 16)
|
||||||
{
|
{
|
||||||
extension = 2 + (value < singularBeta - 78 && !ttCapture);
|
extension = 2 + (value < singularBeta - 78 && !ttCapture);
|
||||||
depth += depth < 16;
|
depth += depth < 16;
|
||||||
|
@ -1090,7 +1090,7 @@ moves_loop: // When in check, search starts here
|
||||||
|
|
||||||
// Add extension to new depth
|
// Add extension to new depth
|
||||||
newDepth += extension;
|
newDepth += extension;
|
||||||
ss->doubleExtensions = (ss - 1)->doubleExtensions + (extension >= 2);
|
ss->multipleExtensions = (ss - 1)->multipleExtensions + (extension >= 2);
|
||||||
|
|
||||||
// Speculative prefetch as early as possible
|
// Speculative prefetch as early as possible
|
||||||
prefetch(tt.first_entry(pos.key_after(move)));
|
prefetch(tt.first_entry(pos.key_after(move)));
|
||||||
|
@ -1142,7 +1142,7 @@ moves_loop: // When in check, search starts here
|
||||||
+ (*contHist[1])[movedPiece][move.to_sq()]
|
+ (*contHist[1])[movedPiece][move.to_sq()]
|
||||||
+ (*contHist[3])[movedPiece][move.to_sq()] - 4409;
|
+ (*contHist[3])[movedPiece][move.to_sq()] - 4409;
|
||||||
|
|
||||||
// Decrease/increase reduction for moves with a good/bad history (~25 Elo)
|
// Decrease/increase reduction for moves with a good/bad history (~8 Elo)
|
||||||
r -= ss->statScore / 14894;
|
r -= ss->statScore / 14894;
|
||||||
|
|
||||||
// Step 17. Late moves reduction / extension (LMR, ~117 Elo)
|
// Step 17. Late moves reduction / extension (LMR, ~117 Elo)
|
||||||
|
@ -1150,7 +1150,7 @@ moves_loop: // When in check, search starts here
|
||||||
{
|
{
|
||||||
// In general we want to cap the LMR depth search at newDepth, but when
|
// In general we want to cap the LMR depth search at newDepth, but when
|
||||||
// reduction is negative, we allow this move a limited search extension
|
// reduction is negative, we allow this move a limited search extension
|
||||||
// beyond the first move depth. This may lead to hidden double extensions.
|
// beyond the first move depth. This may lead to hidden multiple extensions.
|
||||||
// To prevent problems when the max value is less than the min value,
|
// To prevent problems when the max value is less than the min value,
|
||||||
// std::clamp has been replaced by a more robust implementation.
|
// std::clamp has been replaced by a more robust implementation.
|
||||||
Depth d = std::max(1, std::min(newDepth - r, newDepth + 1));
|
Depth d = std::max(1, std::min(newDepth - r, newDepth + 1));
|
||||||
|
@ -1371,8 +1371,8 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||||
assert(PvNode || (alpha == beta - 1));
|
assert(PvNode || (alpha == beta - 1));
|
||||||
assert(depth <= 0);
|
assert(depth <= 0);
|
||||||
|
|
||||||
// Check if we have an upcoming move that draws by repetition, or
|
// Check if we have an upcoming move that draws by repetition, or if
|
||||||
// if the opponent had an alternative move earlier to this position.
|
// the opponent had an alternative move earlier to this position. (~1 Elo)
|
||||||
if (alpha < VALUE_DRAW && pos.has_game_cycle(ss->ply))
|
if (alpha < VALUE_DRAW && pos.has_game_cycle(ss->ply))
|
||||||
{
|
{
|
||||||
alpha = value_draw(this->nodes);
|
alpha = value_draw(this->nodes);
|
||||||
|
@ -1520,7 +1520,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||||
futilityValue = futilityBase + PieceValue[pos.piece_on(move.to_sq())];
|
futilityValue = futilityBase + PieceValue[pos.piece_on(move.to_sq())];
|
||||||
|
|
||||||
// If static eval + value of piece we are going to capture is much lower
|
// If static eval + value of piece we are going to capture is much lower
|
||||||
// than alpha we can prune this move.
|
// than alpha we can prune this move. (~2 Elo)
|
||||||
if (futilityValue <= alpha)
|
if (futilityValue <= alpha)
|
||||||
{
|
{
|
||||||
bestValue = std::max(bestValue, futilityValue);
|
bestValue = std::max(bestValue, futilityValue);
|
||||||
|
@ -1528,7 +1528,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||||
}
|
}
|
||||||
|
|
||||||
// If static eval is much lower than alpha and move is not winning material
|
// If static eval is much lower than alpha and move is not winning material
|
||||||
// we can prune this move.
|
// we can prune this move. (~2 Elo)
|
||||||
if (futilityBase <= alpha && !pos.see_ge(move, VALUE_ZERO + 1))
|
if (futilityBase <= alpha && !pos.see_ge(move, VALUE_ZERO + 1))
|
||||||
{
|
{
|
||||||
bestValue = std::max(bestValue, futilityBase);
|
bestValue = std::max(bestValue, futilityBase);
|
||||||
|
|
11
src/search.h
11
src/search.h
|
@ -67,7 +67,7 @@ struct Stack {
|
||||||
bool inCheck;
|
bool inCheck;
|
||||||
bool ttPv;
|
bool ttPv;
|
||||||
bool ttHit;
|
bool ttHit;
|
||||||
int doubleExtensions;
|
int multipleExtensions;
|
||||||
int cutoffCnt;
|
int cutoffCnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -136,9 +136,8 @@ struct SharedState {
|
||||||
|
|
||||||
class Worker;
|
class Worker;
|
||||||
|
|
||||||
// Null Object Pattern, implement a common interface
|
// Null Object Pattern, implement a common interface for the SearchManagers.
|
||||||
// for the SearchManagers. A Null Object will be given to
|
// A Null Object will be given to non-mainthread workers.
|
||||||
// non-mainthread workers.
|
|
||||||
class ISearchManager {
|
class ISearchManager {
|
||||||
public:
|
public:
|
||||||
virtual ~ISearchManager() {}
|
virtual ~ISearchManager() {}
|
||||||
|
@ -185,8 +184,8 @@ class Worker {
|
||||||
// Reset histories, usually before a new game
|
// Reset histories, usually before a new game
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
// Called when the program receives the UCI 'go'
|
// Called when the program receives the UCI 'go' command.
|
||||||
// command. It searches from the root position and outputs the "bestmove".
|
// It searches from the root position and outputs the "bestmove".
|
||||||
void start_searching();
|
void start_searching();
|
||||||
|
|
||||||
bool is_mainthread() const { return thread_idx == 0; }
|
bool is_mainthread() const { return thread_idx == 0; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue