From 0a01dd044f8a8f291127ebf60462773bf12c90c7 Mon Sep 17 00:00:00 2001 From: Stefan Geschwentner Date: Tue, 9 Aug 2022 20:56:13 +0200 Subject: [PATCH] Cleanup code This PR includes following cleanups: - Remove the unused depth variable in the thread class. - cleanup ValueList (added from mstembera) closes https://github.com/official-stockfish/Stockfish/pull/4127 No functional change. --- src/evaluate.cpp | 1 - src/misc.h | 13 ------------- src/position.cpp | 6 ++++-- src/search.cpp | 1 - src/thread.h | 2 +- 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 9e3eaba5..7d587675 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -1114,7 +1114,6 @@ std::string Eval::trace(Position& pos) { std::memset(scores, 0, sizeof(scores)); // Reset any global variable used in eval - pos.this_thread()->depth = 0; pos.this_thread()->trend = SCORE_ZERO; pos.this_thread()->bestValue = VALUE_ZERO; pos.this_thread()->optimism[WHITE] = VALUE_ZERO; diff --git a/src/misc.h b/src/misc.h index 2fd2b408..fe1143de 100644 --- a/src/misc.h +++ b/src/misc.h @@ -116,23 +116,10 @@ class ValueList { public: std::size_t size() const { return size_; } - void resize(std::size_t newSize) { size_ = newSize; } void push_back(const T& value) { values_[size_++] = value; } - T& operator[](std::size_t index) { return values_[index]; } - T* begin() { return values_; } - T* end() { return values_ + size_; } - const T& operator[](std::size_t index) const { return values_[index]; } const T* begin() const { return values_; } const T* end() const { return values_ + size_; } - void swap(ValueList& other) { - const std::size_t maxSize = std::max(size_, other.size_); - for (std::size_t i = 0; i < maxSize; ++i) { - std::swap(values_[i], other.values_[i]); - } - std::swap(size_, other.size_); - } - private: T values_[MaxSize]; std::size_t size_ = 0; diff --git a/src/position.cpp b/src/position.cpp index ec9229ea..08ed1a89 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1099,10 +1099,12 @@ bool Position::see_ge(Move m, Value threshold) const { // Don't allow pinned pieces to attack as long as there are // pinners on their original square. if (pinners(~stm) & occupied) + { stmAttackers &= ~blockers_for_king(stm); - if (!stmAttackers) - break; + if (!stmAttackers) + break; + } res ^= 1; diff --git a/src/search.cpp b/src/search.cpp index 7c0601e6..565fba0f 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -565,7 +565,6 @@ namespace { // Step 1. Initialize node Thread* thisThread = pos.this_thread(); - thisThread->depth = depth; ss->inCheck = pos.checkers(); priorCapture = pos.captured_piece(); Color us = pos.side_to_move(); diff --git a/src/thread.h b/src/thread.h index 9e9cd488..c430a818 100644 --- a/src/thread.h +++ b/src/thread.h @@ -69,7 +69,7 @@ public: Position rootPos; StateInfo rootState; Search::RootMoves rootMoves; - Depth rootDepth, completedDepth, depth, previousDepth; + Depth rootDepth, completedDepth, previousDepth; Value rootDelta; CounterMoveHistory counterMoves; ButterflyHistory mainHistory; -- 2.39.2