} // namespace
+namespace Stockfish {
+
/// setup_bench() builds a list of UCI commands to be run by bench. There
/// are five parameters: TT size in MB, number of search threads that
/// should be used, the limit value spent for each position, a file name
return list;
}
+
+} // namespace Stockfish
#include "bitboard.h"
#include "types.h"
+namespace Stockfish {
+
namespace {
// There are 24 possible pawn squares: files A to D and ranks from 2 to 7.
} // namespace
-
bool Bitbases::probe(Square wksq, Square wpsq, Square bksq, Color stm) {
assert(file_of(wpsq) <= FILE_D);
KPKBitbase.set(idx);
}
-
namespace {
KPKPosition::KPKPosition(unsigned idx) {
}
} // namespace
+
+} // namespace Stockfish
#include "bitboard.h"
#include "misc.h"
+namespace Stockfish {
+
uint8_t PopCnt16[1 << 16];
uint8_t SquareDistance[SQUARE_NB][SQUARE_NB];
}
-
/// safe_destination() returns the bitboard of target square for the given step
/// from the given square. If the step is off the board, returns empty bitboard.
}
}
-
namespace {
Bitboard sliding_attack(PieceType pt, Square sq, Bitboard occupied) {
}
}
}
+
+} // namespace Stockfish
#include "types.h"
+namespace Stockfish {
+
namespace Bitbases {
void init();
bool probe(Square wksq, Square wpsq, Square bksq, Color us);
-}
+} // namespace Stockfish::Bitbases
namespace Bitboards {
void init();
std::string pretty(Bitboard b);
-}
+} // namespace Stockfish::Bitboards
constexpr Bitboard AllSquares = ~Bitboard(0);
constexpr Bitboard DarkSquares = 0xAA55AA55AA55AA55ULL;
return c == WHITE ? msb(b) : lsb(b);
}
+} // namespace Stockfish
+
#endif // #ifndef BITBOARD_H_INCLUDED
#include "endgame.h"
#include "movegen.h"
+namespace Stockfish {
+
namespace {
// Used to drive the king towards the edge of the board
// it's probably at least a draw even with the pawn.
return Bitbases::probe(strongKing, strongPawn, weakKing, us) ? SCALE_FACTOR_NONE : SCALE_FACTOR_DRAW;
}
+
+} // namespace Stockfish
#include "position.h"
#include "types.h"
+namespace Stockfish {
/// EndgameCode lists all supported endgame functions by corresponding codes
}
}
+} // namespace Stockfish
+
#endif // #ifndef ENDGAME_H_INCLUDED
using namespace std;
-using namespace Eval::NNUE;
+using namespace Stockfish::Eval::NNUE;
+
+namespace Stockfish {
namespace Eval {
return ss.str();
}
+
+} // namespace Stockfish
#include "types.h"
+namespace Stockfish {
+
class Position;
namespace Eval {
} // namespace Eval
+} // namespace Stockfish
+
#endif // #ifndef EVALUATE_H_INCLUDED
#include "tt.h"
#include "uci.h"
+using namespace Stockfish;
+
int main(int argc, char* argv[]) {
std::cout << engine_info() << std::endl;
using namespace std;
+namespace Stockfish {
+
namespace {
#define S(mg, eg) make_score(mg, eg)
}
} // namespace Material
+
+} // namespace Stockfish
#include "position.h"
#include "types.h"
-namespace Material {
+namespace Stockfish::Material {
/// Material::Entry contains various information about a material configuration.
/// It contains a material imbalance evaluation, a function pointer to a special
Entry* probe(const Position& pos);
-} // namespace Material
+} // namespace Stockfish::Material
#endif // #ifndef MATERIAL_H_INCLUDED
using namespace std;
+namespace Stockfish {
+
namespace {
/// Version number. If Version is left empty, then compile date in the format
} // namespace CommandLine
+
+} // namespace Stockfish
#include "types.h"
+namespace Stockfish {
+
std::string engine_info(bool to_uci = false);
std::string compiler_info();
void prefetch(void* addr);
extern std::string workingDirectory; // path of the working directory
}
+} // namespace Stockfish
+
#endif // #ifndef MISC_H_INCLUDED
#include "movegen.h"
#include "position.h"
+namespace Stockfish {
+
namespace {
template<GenType Type, Direction D>
return moveList;
}
+
+} // namespace Stockfish
#include "types.h"
+namespace Stockfish {
+
class Position;
enum GenType {
ExtMove moveList[MAX_MOVES], *last;
};
+} // namespace Stockfish
+
#endif // #ifndef MOVEGEN_H_INCLUDED
#include "movepick.h"
+namespace Stockfish {
+
namespace {
enum Stages {
assert(false);
return MOVE_NONE; // Silence warning
}
+
+} // namespace Stockfish
#include "position.h"
#include "types.h"
+namespace Stockfish {
+
/// StatsEntry stores the stat table value. It is usually a number but could
/// be a move or even a nested history. We use a class instead of naked value
/// to directly call history update operator<<() on the entry so to use stats
ExtMove moves[MAX_MOVES];
};
+} // namespace Stockfish
+
#endif // #ifndef MOVEPICK_H_INCLUDED
#include "../layers/affine_transform.h"
#include "../layers/clipped_relu.h"
-namespace Eval::NNUE {
+namespace Stockfish::Eval::NNUE {
// Input features used in evaluation function
using RawFeatures = Features::FeatureSet<
using Network = Layers::OutputLayer;
-} // namespace Eval::NNUE
+} // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_HALFKP_256X2_32_32_H_INCLUDED
#include "evaluate_nnue.h"
-namespace Eval::NNUE {
+namespace Stockfish::Eval::NNUE {
// Input feature converter
LargePagePtr<FeatureTransformer> feature_transformer;
return ReadParameters(stream);
}
-} // namespace Eval::NNUE
+} // namespace Stockfish::Eval::NNUE
#include <memory>
-namespace Eval::NNUE {
+namespace Stockfish::Eval::NNUE {
// Hash value of evaluation function structure
constexpr std::uint32_t kHashValue =
template <typename T>
using LargePagePtr = std::unique_ptr<T, LargePageDeleter<T>>;
-} // namespace Eval::NNUE
+} // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_EVALUATE_NNUE_H_INCLUDED
#include "features_common.h"
#include <array>
-namespace Eval::NNUE::Features {
+namespace Stockfish::Eval::NNUE::Features {
// Class template that represents a list of values
template <typename T, T... Values>
};
-} // namespace Eval::NNUE::Features
+} // namespace Stockfish::Eval::NNUE::Features
#endif // #ifndef NNUE_FEATURE_SET_H_INCLUDED
#include "../../evaluate.h"
#include "../nnue_common.h"
-namespace Eval::NNUE::Features {
+namespace Stockfish::Eval::NNUE::Features {
class IndexList;
kFriend // side to move
};
-} // namespace Eval::NNUE::Features
+} // namespace Stockfish::Eval::NNUE::Features
#endif // #ifndef NNUE_FEATURES_COMMON_H_INCLUDED
#include "half_kp.h"
#include "index_list.h"
-namespace Eval::NNUE::Features {
+namespace Stockfish::Eval::NNUE::Features {
// Orient a square according to perspective (rotates by 180 for black)
inline Square orient(Color perspective, Square s) {
template class HalfKP<Side::kFriend>;
-} // namespace Eval::NNUE::Features
+} // namespace Stockfish::Eval::NNUE::Features
#include "../../evaluate.h"
#include "features_common.h"
-namespace Eval::NNUE::Features {
+namespace Stockfish::Eval::NNUE::Features {
// Feature HalfKP: Combination of the position of own king
// and the position of pieces other than kings
IndexList* removed, IndexList* added);
};
-} // namespace Eval::NNUE::Features
+} // namespace Stockfish::Eval::NNUE::Features
#endif // #ifndef NNUE_FEATURES_HALF_KP_H_INCLUDED
#include "../../position.h"
#include "../nnue_architecture.h"
-namespace Eval::NNUE::Features {
+namespace Stockfish::Eval::NNUE::Features {
// Class template used for feature index list
template <typename T, std::size_t MaxSize>
: public ValueList<IndexType, RawFeatures::kMaxActiveDimensions> {
};
-} // namespace Eval::NNUE::Features
+} // namespace Stockfish::Eval::NNUE::Features
#endif // NNUE_FEATURES_INDEX_LIST_H_INCLUDED
#include <iostream>
#include "../nnue_common.h"
-namespace Eval::NNUE::Layers {
+namespace Stockfish::Eval::NNUE::Layers {
// Affine transformation layer
template <typename PreviousLayer, IndexType OutputDimensions>
#endif
};
-} // namespace Eval::NNUE::Layers
+} // namespace Stockfish::Eval::NNUE::Layers
#endif // #ifndef NNUE_LAYERS_AFFINE_TRANSFORM_H_INCLUDED
#include "../nnue_common.h"
-namespace Eval::NNUE::Layers {
+namespace Stockfish::Eval::NNUE::Layers {
// Clipped ReLU
template <typename PreviousLayer>
PreviousLayer previous_layer_;
};
-} // namespace Eval::NNUE::Layers
+} // namespace Stockfish::Eval::NNUE::Layers
#endif // NNUE_LAYERS_CLIPPED_RELU_H_INCLUDED
#include "../nnue_common.h"
-namespace Eval::NNUE::Layers {
+namespace Stockfish::Eval::NNUE::Layers {
// Input layer
template <IndexType OutputDimensions, IndexType Offset = 0>
private:
};
-} // namespace Layers
+} // namespace Stockfish::Eval::NNUE::Layers
#endif // #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED
#include "nnue_architecture.h"
-namespace Eval::NNUE {
+namespace Stockfish::Eval::NNUE {
// The accumulator of a StateInfo without parent is set to the INIT state
enum AccumulatorState { EMPTY, COMPUTED, INIT };
AccumulatorState state[2];
};
-} // namespace Eval::NNUE
+} // namespace Stockfish::Eval::NNUE
#endif // NNUE_ACCUMULATOR_H_INCLUDED
// Defines the network structure
#include "architectures/halfkp_256x2-32-32.h"
-namespace Eval::NNUE {
+namespace Stockfish::Eval::NNUE {
static_assert(kTransformedFeatureDimensions % kMaxSimdWidth == 0, "");
static_assert(Network::kOutputDimensions == 1, "");
// Trigger for full calculation instead of difference calculation
constexpr auto kRefreshTriggers = RawFeatures::kRefreshTriggers;
-} // namespace Eval::NNUE
+} // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_ARCHITECTURE_H_INCLUDED
#include <arm_neon.h>
#endif
-namespace Eval::NNUE {
+namespace Stockfish::Eval::NNUE {
// Version of the evaluation file
constexpr std::uint32_t kVersion = 0x7AF32F16u;
return result;
}
-} // namespace Eval::NNUE
+} // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_COMMON_H_INCLUDED
#include <cstring> // std::memset()
-namespace Eval::NNUE {
+namespace Stockfish::Eval::NNUE {
// If vector instructions are enabled, we update and refresh the
// accumulator tile by tile such that each tile fits in the CPU's
WeightType weights_[kHalfDimensions * kInputDimensions];
};
-} // namespace Eval::NNUE
+} // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_FEATURE_TRANSFORMER_H_INCLUDED
#include "position.h"
#include "thread.h"
+namespace Stockfish {
+
namespace {
#define V Value
template Score Entry::do_king_safety<BLACK>(const Position& pos);
} // namespace Pawns
+
+} // namespace Stockfish
#include "position.h"
#include "types.h"
-namespace Pawns {
+namespace Stockfish::Pawns {
/// Pawns::Entry contains various information about a pawn structure. A lookup
/// to the pawn hash table (performed by calling the probe function) returns a
Entry* probe(const Position& pos);
-} // namespace Pawns
+} // namespace Stockfish::Pawns
#endif // #ifndef PAWNS_H_INCLUDED
using std::string;
+namespace Stockfish {
+
namespace Zobrist {
Key psq[PIECE_NB][SQUARE_NB];
return true;
}
+
+} // namespace Stockfish
#include "nnue/nnue_accumulator.h"
+namespace Stockfish {
/// StateInfo struct stores information needed to restore a Position object to
/// its previous state when we retract a move. Whenever a move is made on the
return st;
}
+} // namespace Stockfish
+
#endif // #ifndef POSITION_H_INCLUDED
#include "bitboard.h"
#include "types.h"
+namespace Stockfish {
namespace
{
}
} // namespace PSQT
+
+} // namespace Stockfish
#include "types.h"
-namespace PSQT
+namespace Stockfish::PSQT
{
extern Score psq[PIECE_NB][SQUARE_NB];
// Fill psqt array from a set of internally linked parameters
extern void init();
-} // namespace PSQT
+} // namespace Stockfish::PSQT
#endif // PSQT_H_INCLUDED
#include "uci.h"
#include "syzygy/tbprobe.h"
+namespace Stockfish {
+
namespace Search {
LimitsType Limits;
while (true)
{
Depth adjustedDepth = std::max(1, rootDepth - failedHighCnt - searchAgainCounter);
- bestValue = ::search<PV>(rootPos, ss, alpha, beta, adjustedDepth, false);
+ bestValue = Stockfish::search<PV>(rootPos, ss, alpha, beta, adjustedDepth, false);
// Bring the best move to the front. It is critical that sorting
// is done with a stable algorithm because all the values but the
m.tbRank = 0;
}
}
+
+} // namespace Stockfish
#include "movepick.h"
#include "types.h"
+namespace Stockfish {
+
class Position;
namespace Search {
} // namespace Search
+} // namespace Stockfish
+
#endif // #ifndef SEARCH_H_INCLUDED
#include <windows.h>
#endif
-using namespace Tablebases;
+using namespace Stockfish::Tablebases;
-int Tablebases::MaxCardinality;
+int Stockfish::Tablebases::MaxCardinality;
+
+namespace Stockfish {
namespace {
return true;
}
+
+} // namespace Stockfish
#include "../search.h"
-namespace Tablebases {
+namespace Stockfish::Tablebases {
enum WDLScore {
WDLLoss = -2, // Loss
return os;
}
-}
+} // namespace Stockfish::Tablebases
#endif
#include "syzygy/tbprobe.h"
#include "tt.h"
+namespace Stockfish {
+
ThreadPool Threads; // Global object
if (th != front())
th->wait_for_search_finished();
}
+
+} // namespace Stockfish
#include "search.h"
#include "thread_win32_osx.h"
+namespace Stockfish {
/// Thread class keeps together all the thread-related stuff. We use
/// per-thread pawn and material hash tables so that once we get a
extern ThreadPool Threads;
+} // namespace Stockfish
+
#endif // #ifndef THREAD_H_INCLUDED
#include <pthread.h>
+namespace Stockfish {
+
static const size_t TH_STACK_SIZE = 8 * 1024 * 1024;
template <class T, class P = std::pair<T*, void(T::*)()>>
void join() { pthread_join(thread, NULL); }
};
+} // namespace Stockfish
+
#else // Default case: use STL classes
+namespace Stockfish {
+
typedef std::thread NativeThread;
+} // namespace Stockfish
+
#endif
#endif // #ifndef THREAD_WIN32_OSX_H_INCLUDED
#include "timeman.h"
#include "uci.h"
+namespace Stockfish {
+
TimeManagement Time; // Our global time management object
if (Options["Ponder"])
optimumTime += optimumTime / 4;
}
+
+} // namespace Stockfish
#include "search.h"
#include "thread.h"
+namespace Stockfish {
+
/// The TimeManagement class computes the optimal time to think depending on
/// the maximum available time, the game move number and other parameters.
extern TimeManagement Time;
+} // namespace Stockfish
+
#endif // #ifndef TIMEMAN_H_INCLUDED
#include "tt.h"
#include "uci.h"
+namespace Stockfish {
+
TranspositionTable TT; // Our global transposition table
/// TTEntry::save() populates the TTEntry with a new node's data, possibly
return cnt / ClusterSize;
}
+
+} // namespace Stockfish
#include "misc.h"
#include "types.h"
+namespace Stockfish {
+
/// TTEntry struct is the 10 bytes transposition table entry, defined as below:
///
/// key 16 bit
extern TranspositionTable TT;
+} // namespace Stockfish
+
#endif // #ifndef TT_H_INCLUDED
using std::string;
+namespace Stockfish {
+
bool Tune::update_on_last;
const UCI::Option* LastOption = nullptr;
BoolConditions Conditions;
sync_cout << binary[i] << sync_endl;
}
+} // namespace Stockfish
+
// Init options with tuning session results instead of default values. Useful to
// get correct bench signature after a tuning session or to test tuned values.
#include <cmath>
+namespace Stockfish {
+
void Tune::read_results() {
/* ...insert your values here... */
}
+
+} // namespace Stockfish
#include <type_traits>
#include <vector>
+namespace Stockfish {
+
typedef std::pair<int, int> Range; // Option's min-max values
typedef Range (RangeFun) (int);
#define TUNE_CONDITIONS() int UNIQUE(c, __LINE__) = (Conditions.init(__COUNTER__), 0); \
TUNE(Conditions, set_conditions)
+} // namespace Stockfish
+
#endif // #ifndef TUNE_H_INCLUDED
# define pext(b, m) 0
#endif
+namespace Stockfish {
+
#ifdef USE_POPCNT
constexpr bool HasPopCnt = true;
#else
return seed * 6364136223846793005ULL + 1442695040888963407ULL;
}
+} // namespace Stockfish
+
#endif // #ifndef TYPES_H_INCLUDED
#include "tune.h" // Global visibility to tuning setup
using namespace std;
+namespace Stockfish {
+
extern vector<string> setup_bench(const Position&, istream&);
namespace {
return MOVE_NONE;
}
+
+} // namespace Stockfish
#include "types.h"
+namespace Stockfish {
+
class Position;
namespace UCI {
extern UCI::OptionsMap Options;
+} // namespace Stockfish
+
#endif // #ifndef UCI_H_INCLUDED
using std::string;
+namespace Stockfish {
+
UCI::OptionsMap Options; // Global object
namespace UCI {
}
} // namespace UCI
+
+} // namespace Stockfish
threads="2"
cat << EOF > tsan.supp
-race:TTEntry::move
-race:TTEntry::depth
-race:TTEntry::bound
-race:TTEntry::save
-race:TTEntry::value
-race:TTEntry::eval
-race:TTEntry::is_pv
-
-race:TranspositionTable::probe
-race:TranspositionTable::hashfull
+race:Stockfish::TTEntry::move
+race:Stockfish::TTEntry::depth
+race:Stockfish::TTEntry::bound
+race:Stockfish::TTEntry::save
+race:Stockfish::TTEntry::value
+race:Stockfish::TTEntry::eval
+race:Stockfish::TTEntry::is_pv
+
+race:Stockfish::TranspositionTable::probe
+race:Stockfish::TranspositionTable::hashfull
EOF