From f90274d8ce1aad4ad0595aacbceb74b6cbe306a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ste=CC=81phane=20Nicolet?= Date: Mon, 17 May 2021 09:13:34 +0200 Subject: [PATCH 1/1] Small clean-ups - Comment for Countemove pruning -> Continuation history - Fix comment in input_slice.h - Shorter lines in Makefile - Comment for scale factor - Fix comment for pinners in see_ge() - Change Thread.id() signature to size_t - Trailing space in reprosearch.sh - Add Douglas Matos Gomes to the AUTHORS file - Introduce comment for undo_null_move() - Use Stockfish coding style for export_net() - Change date in AUTHORS file closes https://github.com/official-stockfish/Stockfish/pull/3416 No functional change --- AUTHORS | 3 ++- src/Makefile | 6 ++---- src/evaluate.cpp | 28 ++++++++++++++++------------ src/nnue/layers/input_slice.h | 2 +- src/position.cpp | 9 ++++++--- src/search.cpp | 5 ++--- src/thread.h | 2 +- tests/reprosearch.sh | 2 +- 8 files changed, 31 insertions(+), 26 deletions(-) diff --git a/AUTHORS b/AUTHORS index 69d682f1..9042495f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,4 +1,4 @@ -# List of authors for Stockfish, as of March 31, 2021 +# List of authors for Stockfish, as of May 17, 2021 # Founders of the Stockfish project and fishtest infrastructure Tord Romstad (romstad) @@ -52,6 +52,7 @@ Dieter Dobbelaere (ddobbelaere) DiscanX Dominik Schlösser (domschl) double-beep +Douglas Matos Gomes (dsmsgms) Eduardo Cáceres (eduherminio) Eelco de Groot (KingDefender) Elvin Liu (solarlight2) diff --git a/src/Makefile b/src/Makefile index 71105bdb..660a13fb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -96,8 +96,7 @@ endif ifeq ($(ARCH), $(filter $(ARCH), \ x86-64-vnni512 x86-64-vnni256 x86-64-avx512 x86-64-bmi2 x86-64-avx2 \ x86-64-sse41-popcnt x86-64-modern x86-64-ssse3 x86-64-sse3-popcnt \ - x86-64 x86-32-sse41-popcnt x86-32-sse2 x86-32 ppc-64 ppc-32 \ - e2k \ + x86-64 x86-32-sse41-popcnt x86-32-sse2 x86-32 ppc-64 ppc-32 e2k \ armv7 armv7-neon armv8 apple-silicon general-64 general-32)) SUPPORTED_ARCH=true else @@ -840,8 +839,7 @@ config-sanity: net @test "$(optimize)" = "yes" || test "$(optimize)" = "no" @test "$(SUPPORTED_ARCH)" = "true" @test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \ - test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || \ - test "$(arch)" = "e2k" || \ + test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "e2k" || \ test "$(arch)" = "armv7" || test "$(arch)" = "armv8" || test "$(arch)" = "arm64" @test "$(bits)" = "32" || test "$(bits)" = "64" @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no" diff --git a/src/evaluate.cpp b/src/evaluate.cpp index c396e0f7..403d59dd 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -114,24 +114,28 @@ namespace Eval { } } + /// NNUE::export_net() exports the currently loaded network to a file void NNUE::export_net(const std::optional& filename) { std::string actualFilename; - if (filename.has_value()) { - actualFilename = filename.value(); - } else { - if (eval_file_loaded != EvalFileDefaultName) { - sync_cout << "Failed to export a net. A non-embedded net can only be saved if the filename is specified." << sync_endl; - return; - } - actualFilename = EvalFileDefaultName; + + if (filename.has_value()) + actualFilename = filename.value(); + else + { + if (eval_file_loaded != EvalFileDefaultName) + { + sync_cout << "Failed to export a net. A non-embedded net can only be saved if the filename is specified." << sync_endl; + return; + } + actualFilename = EvalFileDefaultName; } ofstream stream(actualFilename, std::ios_base::binary); - if (save_eval(stream)) { + + if (save_eval(stream)) sync_cout << "Network saved successfully to " << actualFilename << "." << sync_endl; - } else { + else sync_cout << "Failed to export a net." << sync_endl; - } } /// NNUE::verify() verifies that the last net used was loaded successfully @@ -927,7 +931,7 @@ namespace { Color strongSide = eg > VALUE_DRAW ? WHITE : BLACK; int sf = me->scale_factor(pos, strongSide); - // If scale factor is not already specific, scale down via general heuristics + // If scale factor is not already specific, scale up/down via general heuristics if (sf == SCALE_FACTOR_NORMAL) { if (pos.opposite_bishops()) diff --git a/src/nnue/layers/input_slice.h b/src/nnue/layers/input_slice.h index bd4d7447..b6bf1727 100644 --- a/src/nnue/layers/input_slice.h +++ b/src/nnue/layers/input_slice.h @@ -53,7 +53,7 @@ class InputSlice { return true; } - // Read network parameters + // Write network parameters bool write_parameters(std::ostream& /*stream*/) const { return true; } diff --git a/src/position.cpp b/src/position.cpp index 2b3be3f7..f1c36156 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -988,7 +988,7 @@ void Position::do_castling(Color us, Square from, Square& to, Square& rfrom, Squ } -/// Position::do(undo)_null_move() is used to do(undo) a "null move": it flips +/// Position::do_null_move() is used to do a "null move": it flips /// the side to move without executing any move on the board. void Position::do_null_move(StateInfo& newSt) { @@ -1027,6 +1027,9 @@ void Position::do_null_move(StateInfo& newSt) { assert(pos_is_ok()); } + +/// Position::undo_null_move() must be used to undo a "null move" + void Position::undo_null_move() { assert(!checkers()); @@ -1092,8 +1095,8 @@ bool Position::see_ge(Move m, Value threshold) const { if (!(stmAttackers = attackers & pieces(stm))) break; - // Don't allow pinned pieces to attack (except the king) as long as - // there are pinners on their original square. + // 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); diff --git a/src/search.cpp b/src/search.cpp index bf6ba6c4..29b334ed 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -862,7 +862,6 @@ namespace { && ttValue != VALUE_NONE && ttValue < probCutBeta)) { - assert(probCutBeta < VALUE_INFINITE); MovePicker mp(pos, ttMove, probCutBeta - ss->staticEval, &captureHistory); @@ -1025,7 +1024,7 @@ moves_loop: // When in check, search starts from here } else { - // Countermoves based pruning (~20 Elo) + // Continuation history based pruning (~20 Elo) if ( lmrDepth < 4 && (*contHist[0])[movedPiece][to_sq(move)] < CounterMovePruneThreshold && (*contHist[1])[movedPiece][to_sq(move)] < CounterMovePruneThreshold) @@ -1528,7 +1527,7 @@ moves_loop: // When in check, search starts from here [pos.moved_piece(move)] [to_sq(move)]; - // CounterMove based pruning + // Continuation history based pruning if ( !captureOrPromotion && bestValue > VALUE_TB_LOSS_IN_MAX_PLY && (*contHist[0])[pos.moved_piece(move)][to_sq(move)] < CounterMovePruneThreshold diff --git a/src/thread.h b/src/thread.h index 4cf5dabb..5785fd25 100644 --- a/src/thread.h +++ b/src/thread.h @@ -55,7 +55,7 @@ public: void idle_loop(); void start_searching(); void wait_for_search_finished(); - int id() const { return idx; } + size_t id() const { return idx; } Pawns::Table pawnsTable; Material::Table materialTable; diff --git a/tests/reprosearch.sh b/tests/reprosearch.sh index 9fd847ff..c1167f7f 100755 --- a/tests/reprosearch.sh +++ b/tests/reprosearch.sh @@ -10,7 +10,7 @@ trap 'error ${LINENO}' ERR echo "reprosearch testing started" -# repeat two short games, separated by ucinewgame. +# repeat two short games, separated by ucinewgame. # with go nodes $nodes they should result in exactly # the same node count for each iteration. cat << EOF > repeat.exp -- 2.39.2