diff --git a/src/eval/evaluate_common.h b/src/eval/evaluate_common.h index 7799fe79..47e69a44 100644 --- a/src/eval/evaluate_common.h +++ b/src/eval/evaluate_common.h @@ -1,8 +1,6 @@ #ifndef _EVALUATE_COMMON_H_ #define _EVALUATE_COMMON_H_ -#if defined(EVAL_LEARN) - // A common header-like function for modern evaluation functions. #include @@ -21,6 +19,4 @@ namespace Eval double get_eta(); } -#endif // defined(EVAL_LEARN) - #endif // _EVALUATE_KPPT_COMMON_H_ diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 3b0b0f88..e619a747 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -43,11 +43,8 @@ namespace Eval { return UseNNUEMode::False; else if (mode == "true") return UseNNUEMode::True; - -#ifdef EVAL_LEARN else if (mode == "pure") return UseNNUEMode::Pure; -#endif return UseNNUEMode::False; } @@ -955,11 +952,9 @@ make_v: /// evaluation of the position from the point of view of the side to move. Value Eval::evaluate(const Position& pos) { -#ifdef EVAL_LEARN if (useNNUE == UseNNUEMode::Pure) { return NNUE::evaluate(pos); } -#endif bool classical = useNNUE == UseNNUEMode::False || abs(eg_value(pos.psq_score())) * 16 > NNUEThreshold1 * (16 + pos.rule50_count()); diff --git a/src/evaluate.h b/src/evaluate.h index 61052e90..900a77fc 100644 --- a/src/evaluate.h +++ b/src/evaluate.h @@ -29,11 +29,8 @@ namespace Eval { enum struct UseNNUEMode { False, - True - -#ifdef EVAL_LEARN - ,Pure -#endif + True, + Pure }; std::string trace(const Position& pos); diff --git a/src/learn/convert.cpp b/src/learn/convert.cpp index e9dcb10b..483296a1 100644 --- a/src/learn/convert.cpp +++ b/src/learn/convert.cpp @@ -1,5 +1,3 @@ -#if defined(EVAL_LEARN) - #include "convert.h" #include "multi_think.h" @@ -606,4 +604,3 @@ namespace Learner convert(args); } } -#endif diff --git a/src/learn/convert.h b/src/learn/convert.h index a79820a3..a41885d9 100644 --- a/src/learn/convert.h +++ b/src/learn/convert.h @@ -5,7 +5,6 @@ #include #include -#if defined(EVAL_LEARN) namespace Learner { void convert_bin_from_pgn_extract( const std::vector& filenames, @@ -32,6 +31,5 @@ namespace Learner { void convert(std::istringstream& is); } -#endif #endif diff --git a/src/learn/gensfen.cpp b/src/learn/gensfen.cpp index ebf47188..afbcce37 100644 --- a/src/learn/gensfen.cpp +++ b/src/learn/gensfen.cpp @@ -1,6 +1,4 @@ -#if defined(EVAL_LEARN) - -#include "gensfen.h" +#include "gensfen.h" #include "packed_sfen.h" #include "multi_think.h" @@ -1207,4 +1205,3 @@ namespace Learner std::cout << "gensfen finished." << endl; } } -#endif diff --git a/src/learn/gensfen.h b/src/learn/gensfen.h index 45e4ca23..d39e44c9 100644 --- a/src/learn/gensfen.h +++ b/src/learn/gensfen.h @@ -5,12 +5,10 @@ #include -#if defined(EVAL_LEARN) namespace Learner { // Automatic generation of teacher position void gen_sfen(Position& pos, std::istringstream& is); } -#endif #endif \ No newline at end of file diff --git a/src/learn/learn.cpp b/src/learn/learn.cpp index 0459dd90..3f951888 100644 --- a/src/learn/learn.cpp +++ b/src/learn/learn.cpp @@ -17,8 +17,6 @@ // → I will not be involved in the engine because it is a problem that the GUI should assist. // etc.. -#if defined(EVAL_LEARN) - #include "learn.h" #include "convert.h" @@ -2048,5 +2046,3 @@ namespace Learner } } // namespace Learner - -#endif // EVAL_LEARN diff --git a/src/learn/learn.h b/src/learn/learn.h index 7ee89009..4b09f825 100644 --- a/src/learn/learn.h +++ b/src/learn/learn.h @@ -1,8 +1,6 @@ #ifndef _LEARN_H_ #define _LEARN_H_ -#if defined(EVAL_LEARN) - // ---------------------- // Floating point for learning // ---------------------- @@ -78,6 +76,4 @@ namespace Learner void learn(Position& pos, std::istringstream& is); } -#endif - #endif // ifndef _LEARN_H_ diff --git a/src/learn/learning_tools.cpp b/src/learn/learning_tools.cpp index 285b3487..925905c6 100644 --- a/src/learn/learning_tools.cpp +++ b/src/learn/learning_tools.cpp @@ -1,7 +1,5 @@ #include "learning_tools.h" -#if defined (EVAL_LEARN) - #include "misc.h" using namespace Eval; @@ -18,5 +16,3 @@ namespace EvalLearningTools uint64_t Weight::eta1_epoch; uint64_t Weight::eta2_epoch; } - -#endif diff --git a/src/learn/learning_tools.h b/src/learn/learning_tools.h index 194a9732..dcb2c4aa 100644 --- a/src/learn/learning_tools.h +++ b/src/learn/learning_tools.h @@ -3,8 +3,6 @@ // A set of machine learning tools related to the weight array used for machine learning of evaluation functions -#if defined (EVAL_LEARN) - #include "learn.h" #include "misc.h" // PRNG , my_insertion_sort @@ -98,5 +96,4 @@ namespace EvalLearningTools }; } -#endif // defined (EVAL_LEARN) #endif diff --git a/src/learn/multi_think.cpp b/src/learn/multi_think.cpp index 28b3e152..043238fa 100644 --- a/src/learn/multi_think.cpp +++ b/src/learn/multi_think.cpp @@ -1,6 +1,4 @@ -#if defined(EVAL_LEARN) - -#include "multi_think.h" +#include "multi_think.h" #include "tt.h" #include "uci.h" @@ -118,6 +116,3 @@ void MultiThink::go_think() Options[s.first] = std::string(s.second); } - - -#endif // defined(EVAL_LEARN) diff --git a/src/learn/multi_think.h b/src/learn/multi_think.h index 4f423da0..7de9d6b9 100644 --- a/src/learn/multi_think.h +++ b/src/learn/multi_think.h @@ -1,8 +1,6 @@ #ifndef _MULTI_THINK_ #define _MULTI_THINK_ -#if defined(EVAL_LEARN) - #include "learn.h" #include "misc.h" @@ -151,6 +149,4 @@ protected: std::mutex task_mutex; }; -#endif // defined(EVAL_LEARN) && defined(YANEURAOU_2018_OTAFUKU_ENGINE) - #endif diff --git a/src/learn/packed_sfen.h b/src/learn/packed_sfen.h index 101e5e34..3aa4fcac 100644 --- a/src/learn/packed_sfen.h +++ b/src/learn/packed_sfen.h @@ -4,7 +4,6 @@ #include #include -#if defined(EVAL_LEARN) namespace Learner { // packed sfen @@ -45,5 +44,3 @@ namespace Learner { using PSVector = std::vector; } #endif - -#endif diff --git a/src/learn/sfen_packer.cpp b/src/learn/sfen_packer.cpp index 791870ca..734a477b 100644 --- a/src/learn/sfen_packer.cpp +++ b/src/learn/sfen_packer.cpp @@ -1,6 +1,4 @@ -#if defined (EVAL_LEARN) - -#include "sfen_packer.h" +#include "sfen_packer.h" #include "packed_sfen.h" @@ -402,6 +400,3 @@ namespace Learner { return sfen; } } - - -#endif // USE_SFEN_PACKER diff --git a/src/learn/sfen_packer.h b/src/learn/sfen_packer.h index af900902..533d3fc9 100644 --- a/src/learn/sfen_packer.h +++ b/src/learn/sfen_packer.h @@ -1,8 +1,6 @@ #ifndef _SFEN_PACKER_H_ #define _SFEN_PACKER_H_ -#if defined(EVAL_LEARN) - #include "types.h" #include "learn/packed_sfen.h" @@ -19,6 +17,4 @@ namespace Learner { PackedSfen sfen_pack(Position& pos); } -#endif - #endif \ No newline at end of file diff --git a/src/nnue/evaluate_nnue_learner.cpp b/src/nnue/evaluate_nnue_learner.cpp index 8b0413e5..ea680e31 100644 --- a/src/nnue/evaluate_nnue_learner.cpp +++ b/src/nnue/evaluate_nnue_learner.cpp @@ -1,7 +1,5 @@ // Code for learning NNUE evaluation function -#if defined(EVAL_LEARN) - #include #include #include @@ -238,5 +236,3 @@ double get_eta() { } } // namespace Eval - -#endif // defined(EVAL_LEARN) diff --git a/src/nnue/evaluate_nnue_learner.h b/src/nnue/evaluate_nnue_learner.h index 0e5fbcd2..e9bd2fd2 100644 --- a/src/nnue/evaluate_nnue_learner.h +++ b/src/nnue/evaluate_nnue_learner.h @@ -3,8 +3,6 @@ #ifndef _EVALUATE_NNUE_LEARNER_H_ #define _EVALUATE_NNUE_LEARNER_H_ -#if defined(EVAL_LEARN) - #include "../learn/learn.h" namespace Eval { @@ -41,6 +39,4 @@ void CheckHealth(); } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer.h b/src/nnue/trainer/trainer.h index 94553c07..659863ad 100644 --- a/src/nnue/trainer/trainer.h +++ b/src/nnue/trainer/trainer.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_H_ #define _NNUE_TRAINER_H_ -#if defined(EVAL_LEARN) - #include "../nnue_common.h" #include "../features/index_list.h" @@ -120,6 +118,4 @@ std::shared_ptr MakeAlignedSharedPtr(ArgumentTypes&&... arguments) { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer_affine_transform.h b/src/nnue/trainer/trainer_affine_transform.h index 4b5ddee6..50751ffe 100644 --- a/src/nnue/trainer/trainer_affine_transform.h +++ b/src/nnue/trainer/trainer_affine_transform.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_AFFINE_TRANSFORM_H_ #define _NNUE_TRAINER_AFFINE_TRANSFORM_H_ -#if defined(EVAL_LEARN) - #include "../../learn/learn.h" #include "../layers/affine_transform.h" #include "trainer.h" @@ -296,6 +294,4 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer_clipped_relu.h b/src/nnue/trainer/trainer_clipped_relu.h index 72575bf8..cf7a2447 100644 --- a/src/nnue/trainer/trainer_clipped_relu.h +++ b/src/nnue/trainer/trainer_clipped_relu.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_CLIPPED_RELU_H_ #define _NNUE_TRAINER_CLIPPED_RELU_H_ -#if defined(EVAL_LEARN) - #include "../../learn/learn.h" #include "../layers/clipped_relu.h" #include "trainer.h" @@ -137,6 +135,4 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer_feature_transformer.h b/src/nnue/trainer/trainer_feature_transformer.h index 6b94d952..190e009a 100644 --- a/src/nnue/trainer/trainer_feature_transformer.h +++ b/src/nnue/trainer/trainer_feature_transformer.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_FEATURE_TRANSFORMER_H_ #define _NNUE_TRAINER_FEATURE_TRANSFORMER_H_ -#if defined(EVAL_LEARN) - #include "../../learn/learn.h" #include "../nnue_feature_transformer.h" #include "trainer.h" @@ -372,6 +370,4 @@ class Trainer { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer_input_slice.h b/src/nnue/trainer/trainer_input_slice.h index 6b0adc9f..e2cd0c25 100644 --- a/src/nnue/trainer/trainer_input_slice.h +++ b/src/nnue/trainer/trainer_input_slice.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_INPUT_SLICE_H_ #define _NNUE_TRAINER_INPUT_SLICE_H_ -#if defined(EVAL_LEARN) - #include "../../learn/learn.h" #include "../layers/input_slice.h" #include "trainer.h" @@ -246,6 +244,4 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer_sum.h b/src/nnue/trainer/trainer_sum.h index 0b7abe36..65a0b681 100644 --- a/src/nnue/trainer/trainer_sum.h +++ b/src/nnue/trainer/trainer_sum.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_SUM_H_ #define _NNUE_TRAINER_SUM_H_ -#if defined(EVAL_LEARN) - #include "../../learn/learn.h" #include "../layers/sum.h" #include "trainer.h" @@ -185,6 +183,4 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/position.cpp b/src/position.cpp index 9465afbc..38ac7c5c 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -32,10 +32,8 @@ #include "uci.h" #include "syzygy/tbprobe.h" -#if defined(EVAL_LEARN) #include "learn/packed_sfen.h" #include "learn/sfen_packer.h" -#endif using std::string; @@ -1352,8 +1350,6 @@ bool Position::pos_is_ok() const { return true; } -#if defined(EVAL_LEARN) - // Add a function that directly unpacks for speed. It's pretty tough. // Write it by combining packer::unpack() and Position::set(). // If there is a problem with the passed phase and there is an error, non-zero is returned. @@ -1385,5 +1381,3 @@ void Position::sfen_pack(Learner::PackedSfen& sfen) { sfen = Learner::sfen_pack(*this); } - -#endif \ No newline at end of file diff --git a/src/position.h b/src/position.h index aa2d34e7..2163dca3 100644 --- a/src/position.h +++ b/src/position.h @@ -30,10 +30,8 @@ #include "nnue/nnue_accumulator.h" -#if defined(EVAL_LEARN) #include "learn/packed_sfen.h" #include "learn/sfen_packer.h" -#endif /// StateInfo struct stores information needed to restore a Position object to @@ -177,7 +175,6 @@ public: // Used by NNUE StateInfo* state() const; -#if defined(EVAL_LEARN) // --sfenization helper friend int Learner::set_from_packed_sfen(Position& pos, const Learner::PackedSfen& sfen, StateInfo* si, Thread* th, bool mirror); @@ -199,7 +196,6 @@ public: // Returns the position of the ball on the c side. Square king_square(Color c) const { return pieceList[make_piece(c, KING)][0]; } -#endif // EVAL_LEARN private: // Initialization helpers (used while setting up a position) diff --git a/src/search.cpp b/src/search.cpp index b92ea7c8..f8cf3cbc 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -54,9 +54,7 @@ using std::string; using Eval::evaluate; using namespace Search; -#if defined(EVAL_LEARN) bool Search::prune_at_shallow_depth_on_pv_node = false; -#endif namespace { @@ -991,9 +989,7 @@ moves_loop: // When in check, search starts from here ss->moveCount = ++moveCount; if (rootNode && thisThread == Threads.main() && Time.elapsed() > 3000 -#if defined(EVAL_LEARN) && !Limits.silent -#endif ) sync_cout << "info depth " << depth << " currmove " << UCI::move(move, pos.is_chess960()) @@ -1011,9 +1007,7 @@ moves_loop: // When in check, search starts from here // Step 12. Pruning at shallow depth (~200 Elo) if ( !rootNode -#ifdef EVAL_LEARN && (PvNode ? prune_at_shallow_depth_on_pv_node : true) -#endif && pos.non_pawn_material(us) && bestValue > VALUE_TB_LOSS_IN_MAX_PLY) { @@ -1564,10 +1558,8 @@ moves_loop: // When in check, search starts from here // Check for legality just before making the move if ( -#if defined(EVAL_LEARN) // HACK: pos.piece_on(from_sq(m)) sometimes will be NO_PIECE during machine learning. !pos.pseudo_legal(move) || -#endif // EVAL_LEARN !pos.legal(move) ) { @@ -1978,7 +1970,6 @@ void Tablebases::rank_root_moves(Position& pos, Search::RootMoves& rootMoves) { // --- expose the functions such as fixed depth search used for learning to the outside -#if defined (EVAL_LEARN) namespace Learner { @@ -2278,4 +2269,3 @@ namespace Learner } } -#endif diff --git a/src/search.h b/src/search.h index 5e092273..20dfe909 100644 --- a/src/search.h +++ b/src/search.h @@ -32,10 +32,7 @@ namespace Search { /// Threshold used for countermoves based pruning constexpr int CounterMovePruneThreshold = 0; - -#if defined(EVAL_LEARN) extern bool prune_at_shallow_depth_on_pv_node; -#endif /// Stack struct keeps track of the information we need to remember from nodes /// shallower and deeper in the tree during the search. Each search thread has @@ -90,9 +87,7 @@ struct LimitsType { time[WHITE] = time[BLACK] = inc[WHITE] = inc[BLACK] = npmsec = movetime = TimePoint(0); movestogo = depth = mate = perft = infinite = 0; nodes = 0; -#if defined (EVAL_LEARN) silent = false; -#endif } bool use_time_management() const { @@ -103,11 +98,9 @@ struct LimitsType { TimePoint time[COLOR_NB], inc[COLOR_NB], npmsec, movetime, startTime; int movestogo, depth, mate, perft, infinite; int64_t nodes; -#if defined (EVAL_LEARN) // Silent mode that does not output to the screen (for continuous self-play in process) // Do not output PV at this time. bool silent; -#endif }; extern LimitsType Limits; @@ -117,7 +110,6 @@ void clear(); } // namespace Search -#if defined(EVAL_LEARN) namespace Learner { // A pair of reader and evaluation value. Returned by Learner::search(),Learner::qsearch(). @@ -126,6 +118,5 @@ namespace Learner { ValueAndPV qsearch(Position& pos); ValueAndPV search(Position& pos, int depth_, size_t multiPV = 1, uint64_t nodesLimit = 0); } -#endif #endif // #ifndef SEARCH_H_INCLUDED diff --git a/src/tt.cpp b/src/tt.cpp index fc8ab3b1..c64670ac 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -28,9 +28,7 @@ TranspositionTable TT; // Our global transposition table -#ifdef EVAL_LEARN bool TranspositionTable::enable_transposition_table = true; -#endif /// TTEntry::save() populates the TTEntry with a new node's data, possibly /// overwriting an old position. Update is not atomic and can be racy. @@ -120,12 +118,10 @@ void TranspositionTable::clear() { TTEntry* TranspositionTable::probe(const Key key, bool& found) const { -#ifdef EVAL_LEARN if (!enable_transposition_table) { found = false; return first_entry(0); } -#endif TTEntry* const tte = first_entry(key); const uint16_t key16 = (uint16_t)key; // Use the low 16 bits as key inside the cluster diff --git a/src/tt.h b/src/tt.h index e83b6f3c..29072bd8 100644 --- a/src/tt.h +++ b/src/tt.h @@ -84,9 +84,7 @@ public: return &table[mul_hi64(key, clusterCount)].entry[0]; } -#ifdef EVAL_LEARN static bool enable_transposition_table; -#endif private: friend struct TTEntry; diff --git a/src/uci.cpp b/src/uci.cpp index 0a28fc1f..1128d4d9 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -245,7 +245,6 @@ double UCI::win_rate_model_double(double v, int ply) { // Call qsearch(),search() directly for testing // -------------------- -#if defined(EVAL_LEARN) void qsearch_cmd(Position& pos) { cout << "qsearch : "; @@ -277,8 +276,6 @@ void search_cmd(Position& pos, istringstream& is) cout << endl; } -#endif - /// UCI::loop() waits for a command from stdin, parses it and calls the appropriate /// function. Also intercepts EOF from stdin to ensure gracefully exiting if the /// GUI dies unexpectedly. When called with some command line arguments, e.g. to @@ -334,7 +331,7 @@ void UCI::loop(int argc, char* argv[]) { else if (token == "d") sync_cout << pos << sync_endl; else if (token == "eval") trace_eval(pos); else if (token == "compiler") sync_cout << compiler_info() << sync_endl; -#if defined (EVAL_LEARN) + else if (token == "gensfen") Learner::gen_sfen(pos, is); else if (token == "learn") Learner::learn(pos, is); else if (token == "convert") Learner::convert(is); @@ -343,8 +340,6 @@ void UCI::loop(int argc, char* argv[]) { else if (token == "qsearch") qsearch_cmd(pos); else if (token == "search") search_cmd(pos, is); -#endif - // test command else if (token == "test") test_cmd(pos, is); else diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 91fa199b..aa85dc07 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -42,14 +42,12 @@ void on_threads(const Option& o) { Threads.set(size_t(o)); } void on_tb_path(const Option& o) { Tablebases::init(o); } void on_use_NNUE(const Option& ) { Eval::init_NNUE(); } void on_eval_file(const Option& ) { Eval::init_NNUE(); } -#ifdef EVAL_LEARN void on_prune_at_shallow_depth_on_pv_node(const Option& o) { Search::prune_at_shallow_depth_on_pv_node = o; } void on_enable_transposition_table(const Option& o) { TranspositionTable::enable_transposition_table = o; } -#endif /// Our case insensitive less() function as required by UCI protocol bool CaseInsensitiveLess::operator() (const string& s1, const string& s2) const { @@ -86,11 +84,7 @@ void init(OptionsMap& o) { o["SyzygyProbeDepth"] << Option(1, 1, 100); o["Syzygy50MoveRule"] << Option(true); o["SyzygyProbeLimit"] << Option(7, 0, 7); -#if defined(EVAL_LEARN) o["Use NNUE"] << Option("true var true var false var pure", "true", on_use_NNUE); -#else - o["Use NNUE"] << Option("true var true var false", "true", on_use_NNUE); -#endif // The default must follow the format nn-[SHA256 first 12 digits].nnue // for the build process (profile-build and fishtest) to work. o["EvalFile"] << Option("nn-82215d0fd0df.nnue", on_eval_file); @@ -102,7 +96,6 @@ void init(OptionsMap& o) { o["SkipLoadingEval"] << Option(false); // how many moves to use a fixed move // o["BookMoves"] << Option(16, 0, 10000); -#if defined(EVAL_LEARN) // When learning the evaluation function, you can change the folder to save the evaluation function. // Evalsave by default. This folder shall be prepared in advance. // Automatically create a folder under this folder like "0/", "1/", ... and save the evaluation function file there. @@ -111,7 +104,6 @@ void init(OptionsMap& o) { o["PruneAtShallowDepthOnPvNode"] << Option(false, on_prune_at_shallow_depth_on_pv_node); // Enable transposition table. o["EnableTranspositionTable"] << Option(true, on_enable_transposition_table); -#endif }