From 2d6a23573a24fa4471af0d3e6d0a4e0399ecbac8 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sat, 1 May 2021 20:40:39 +0800 Subject: [PATCH] Clean up --- src/bitboard.cpp | 6 ------ src/bitboard.h | 9 --------- src/mills.cpp | 1 + src/movegen.cpp | 14 +++----------- src/movepick.cpp | 8 +------- src/position.cpp | 11 ----------- src/rule.cpp | 1 - src/search.cpp | 22 +++------------------- src/search.h | 4 ---- src/stack.h | 3 --- src/thread.cpp | 15 +++------------ src/tt.cpp | 2 +- src/uci.cpp | 9 --------- src/ucioption.cpp | 7 +------ 14 files changed, 13 insertions(+), 99 deletions(-) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 0829b536..b00a0488 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -24,9 +24,6 @@ uint8_t PopCnt16[1 << 16]; Bitboard SquareBB[SQ_32]; -Bitboard StarSquareBB9; -Bitboard StarSquareBB12; - /// Bitboards::pretty() returns an ASCII representation of a bitboard suitable /// to be printed to standard output. Useful for debugging. @@ -57,7 +54,4 @@ void Bitboards::init() for (Square s = SQ_BEGIN; s < SQ_END; ++s) SquareBB[s] = (1UL << s); - - StarSquareBB9 = S4(16, 18, 20, 22); - StarSquareBB12 = S4(17, 19, 21, 23); } diff --git a/src/bitboard.h b/src/bitboard.h index a0eaa88b..8f2e989b 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -69,15 +69,6 @@ inline Bitboard square_bb(Square s) noexcept return SquareBB[s]; } -inline Bitboard star_square_bb_9() noexcept -{ - return StarSquareBB9; -} - -inline Bitboard star_square_bb_12() noexcept -{ - return StarSquareBB12; -} /// Overloads of bitwise operators between a Bitboard and a Square for testing /// whether a given bit is set in a bitboard, and for setting and clearing bits. diff --git a/src/mills.cpp b/src/mills.cpp index add3418e..477518b8 100644 --- a/src/mills.cpp +++ b/src/mills.cpp @@ -16,6 +16,7 @@ along with this program. If not, see . */ +#include #include #include "bitboard.h" diff --git a/src/movegen.cpp b/src/movegen.cpp index 05f13e5e..dc80400f 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -16,16 +16,8 @@ along with this program. If not, see . */ -#include -#include -#include -#include - #include "movegen.h" #include "position.h" -#include "misc.h" -#include "bitboard.h" -#include "option.h" #include "mills.h" /// generate generates all places. @@ -44,7 +36,7 @@ ExtMove *generate(Position &pos, ExtMove *moveList) return cur; } -/// generate generates all places. +/// generate generates all moves. /// Returns a pointer to the end of the move moves. template<> ExtMove *generate(Position &pos, ExtMove *moveList) @@ -81,7 +73,7 @@ ExtMove *generate(Position &pos, ExtMove *moveList) return cur; } -/// generate generates all removes. +/// generate generates all removes. /// Returns a pointer to the end of the move moves. template<> ExtMove *generate(Position &pos, ExtMove *moveList) @@ -145,7 +137,7 @@ ExtMove *generate(Position &pos, ExtMove *moveList) default: #ifdef FLUTTER_UI - LOGD("generate(): action = %d\n", pos.get_action()); + LOGD("generate(): action = %hu\n", pos.get_action()); #endif assert(0); break; diff --git a/src/movepick.cpp b/src/movepick.cpp index b1284062..d2934ff1 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -16,8 +16,6 @@ along with this program. If not, see . */ -#include - #include "movepick.h" // partial_insertion_sort() sorts moves in descending order up to and including @@ -34,11 +32,7 @@ void partial_insertion_sort(ExtMove *begin, const ExtMove *end, int limit) } } -/// Constructors of the MovePicker class. As arguments we pass information -/// to help it to return the (presumably) good moves first, to decide which -/// moves to return (in the quiescence search, for instance, we only want to -/// search captures, promotions, and some checks) and how important good move -/// ordering is at the current node. +/// Constructors of the MovePicker class. /// MovePicker constructor for the main search MovePicker::MovePicker(Position &p) noexcept diff --git a/src/position.cpp b/src/position.cpp index 8df68514..44118dda 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -16,23 +16,12 @@ along with this program. If not, see . */ -#include -#include -#include // For offsetof() -#include // For std::memset, std::memcmp #include #include #include "bitboard.h" -#include "misc.h" -#include "movegen.h" #include "position.h" #include "thread.h" -#include "tt.h" -#include "uci.h" - -#include "option.h" -#include "rule.h" #include "mills.h" using std::string; diff --git a/src/rule.cpp b/src/rule.cpp index 4b44a985..e79e12c1 100644 --- a/src/rule.cpp +++ b/src/rule.cpp @@ -19,7 +19,6 @@ #include #include "rule.h" -#include "types.h" struct Rule rule = { "打三棋(12连棋)", // 打三棋 diff --git a/src/search.cpp b/src/search.cpp index bba1ed85..94e63d6d 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -16,29 +16,13 @@ along with this program. If not, see . */ -#include -#include -#include -#include // For std::memset -#include -#include - #include "evaluate.h" -#include "misc.h" -#include "movegen.h" -#include "movepick.h" -#include "position.h" -#include "search.h" #include "thread.h" -#include "tt.h" -#include "uci.h" +//#include "uci.h" #include "endgame.h" -#include "types.h" #include "option.h" -#include - using std::string; using Eval::evaluate; using namespace Search; @@ -49,7 +33,7 @@ Value search(Position *pos, Sanmill::Stack &ss, Depth depth, Depth ori bool is_timeout(TimePoint startTime); -/// Search::init() is called at startup to initialize various lookup tables +/// Search::init() is called at startup void Search::init() noexcept { @@ -437,7 +421,7 @@ Value search(Position *pos, Sanmill::Stack &ss, Depth depth, Depth ori // Check for a new best move // Finished searching the move. If a stop occurred, the return value of // the search cannot be trusted, and we return immediately without - // updating best move, PV and TT. + // updating best move and TT. if (Threads.stop.load(std::memory_order_relaxed)) return VALUE_ZERO; diff --git a/src/search.h b/src/search.h index 94f320e4..9b84fe93 100644 --- a/src/search.h +++ b/src/search.h @@ -21,11 +21,7 @@ #include -#include "stack.h" -#include "tt.h" #include "endgame.h" -#include "movepick.h" -#include "types.h" #ifdef CYCLE_STAT #include "stopwatch.h" diff --git a/src/stack.h b/src/stack.h index c0c2d556..eb80d68c 100644 --- a/src/stack.h +++ b/src/stack.h @@ -19,9 +19,6 @@ #ifndef STACK_H #define STACK_H -#include -#include - namespace Sanmill { diff --git a/src/thread.cpp b/src/thread.cpp index 6fa18f18..6b697fc3 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -16,15 +16,10 @@ along with this program. If not, see . */ -#include - -#include // For std::count #include -#include "movegen.h" -#include "search.h" + #include "thread.h" #include "uci.h" -#include "tt.h" #include "option.h" #include "mills.h" @@ -84,7 +79,7 @@ Thread::~Thread() void Thread::clear() noexcept { - // TODO: Do nothing + // TODO: Reset histories return; } @@ -549,11 +544,7 @@ void ThreadPool::start_thinking(Position *pos, bool ponderMode) increaseDepth = true; main()->ponder = ponderMode; - // We use Position::set() to set root position across threads. But there are - // some StateInfo fields (previous, pliesFromNull, capturedPiece) that cannot - // be deduced from a fen string, so set() clears them and they are set from - // setupStates->back() later. The rootState is per thread, earlier states are shared - // since they are read-only. + // We use Position::set() to set root position across threads. for (Thread *th : *this) { th->rootPos = pos; } diff --git a/src/tt.cpp b/src/tt.cpp index edbed2bc..e6d46027 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -20,7 +20,7 @@ #ifdef TRANSPOSITION_TABLE_ENABLE -static constexpr int TRANSPOSITION_TABLE_SIZE = 0x1000000; // 8-128M:102s, 4-64M:93s 2-32M:91s 1-16M: 冲突 +static constexpr int TRANSPOSITION_TABLE_SIZE = 0x1000000; HashMap TT(TRANSPOSITION_TABLE_SIZE); #ifdef TRANSPOSITION_TABLE_FAKE_CLEAN diff --git a/src/uci.cpp b/src/uci.cpp index 106c4d15..9000db96 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -16,19 +16,10 @@ along with this program. If not, see . */ -#include -#include #include -#include -#include "evaluate.h" -#include "movegen.h" -#include "position.h" -#include "search.h" #include "thread.h" -#include "tt.h" #include "uci.h" -#include "rule.h" #ifdef FLUTTER_UI #include "command_channel.h" diff --git a/src/ucioption.cpp b/src/ucioption.cpp index d22ad9a1..f5380337 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -16,15 +16,10 @@ along with this program. If not, see . */ -#include -#include -#include #include -#include "misc.h" -#include "search.h" +//#include "misc.h" #include "thread.h" -#include "tt.h" #include "uci.h" #include "option.h"