mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Add Stockfish namespace.
fixes #3350 and is a small cleanup that might make it easier to use SF in separate projects, like a NNUE trainer or similar. closes https://github.com/official-stockfish/Stockfish/pull/3370 No functional change.
This commit is contained in:
parent
9b1274aba3
commit
7ffae17f85
56 changed files with 199 additions and 57 deletions
|
@ -92,6 +92,8 @@ const vector<string> Defaults = {
|
|||
|
||||
} // 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
|
||||
|
@ -168,3 +170,5 @@ vector<string> setup_bench(const Position& current, istream& is) {
|
|||
|
||||
return list;
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#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.
|
||||
|
@ -66,7 +68,6 @@ namespace {
|
|||
|
||||
} // namespace
|
||||
|
||||
|
||||
bool Bitbases::probe(Square wksq, Square wpsq, Square bksq, Color stm) {
|
||||
|
||||
assert(file_of(wpsq) <= FILE_D);
|
||||
|
@ -96,7 +97,6 @@ void Bitbases::init() {
|
|||
KPKBitbase.set(idx);
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
KPKPosition::KPKPosition(unsigned idx) {
|
||||
|
@ -168,3 +168,5 @@ namespace {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "bitboard.h"
|
||||
#include "misc.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
uint8_t PopCnt16[1 << 16];
|
||||
uint8_t SquareDistance[SQUARE_NB][SQUARE_NB];
|
||||
|
||||
|
@ -42,7 +44,6 @@ namespace {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/// 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.
|
||||
|
||||
|
@ -111,7 +112,6 @@ void Bitboards::init() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
Bitboard sliding_attack(PieceType pt, Square sq, Bitboard occupied) {
|
||||
|
@ -211,3 +211,5 @@ namespace {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -23,19 +23,21 @@
|
|||
|
||||
#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;
|
||||
|
@ -430,4 +432,6 @@ inline Square frontmost_sq(Color c, Bitboard b) {
|
|||
return c == WHITE ? msb(b) : lsb(b);
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef BITBOARD_H_INCLUDED
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "endgame.h"
|
||||
#include "movegen.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace {
|
||||
|
||||
// Used to drive the king towards the edge of the board
|
||||
|
@ -741,3 +743,5 @@ ScaleFactor Endgame<KPKP>::operator()(const Position& pos) const {
|
|||
// 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
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "position.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
/// EndgameCode lists all supported endgame functions by corresponding codes
|
||||
|
||||
|
@ -120,4 +121,6 @@ namespace Endgames {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef ENDGAME_H_INCLUDED
|
||||
|
|
|
@ -54,7 +54,9 @@
|
|||
|
||||
|
||||
using namespace std;
|
||||
using namespace Eval::NNUE;
|
||||
using namespace Stockfish::Eval::NNUE;
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace Eval {
|
||||
|
||||
|
@ -1146,3 +1148,5 @@ std::string Eval::trace(const Position& pos) {
|
|||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
class Position;
|
||||
|
||||
namespace Eval {
|
||||
|
@ -49,4 +51,6 @@ namespace Eval {
|
|||
|
||||
} // namespace Eval
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef EVALUATE_H_INCLUDED
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "tt.h"
|
||||
#include "uci.h"
|
||||
|
||||
using namespace Stockfish;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
std::cout << engine_info() << std::endl;
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace {
|
||||
#define S(mg, eg) make_score(mg, eg)
|
||||
|
||||
|
@ -223,3 +225,5 @@ Entry* probe(const Position& pos) {
|
|||
}
|
||||
|
||||
} // namespace Material
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#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
|
||||
|
@ -66,6 +66,6 @@ typedef HashTable<Entry, 8192> Table;
|
|||
|
||||
Entry* probe(const Position& pos);
|
||||
|
||||
} // namespace Material
|
||||
} // namespace Stockfish::Material
|
||||
|
||||
#endif // #ifndef MATERIAL_H_INCLUDED
|
||||
|
|
|
@ -61,6 +61,8 @@ typedef bool(*fun3_t)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace {
|
||||
|
||||
/// Version number. If Version is left empty, then compile date in the format
|
||||
|
@ -626,3 +628,5 @@ void init(int argc, char* argv[]) {
|
|||
|
||||
|
||||
} // namespace CommandLine
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
std::string engine_info(bool to_uci = false);
|
||||
std::string compiler_info();
|
||||
void prefetch(void* addr);
|
||||
|
@ -143,4 +145,6 @@ namespace CommandLine {
|
|||
extern std::string workingDirectory; // path of the working directory
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef MISC_H_INCLUDED
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "movegen.h"
|
||||
#include "position.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace {
|
||||
|
||||
template<GenType Type, Direction D>
|
||||
|
@ -362,3 +364,5 @@ ExtMove* generate<LEGAL>(const Position& pos, ExtMove* moveList) {
|
|||
|
||||
return moveList;
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
class Position;
|
||||
|
||||
enum GenType {
|
||||
|
@ -70,4 +72,6 @@ private:
|
|||
ExtMove moveList[MAX_MOVES], *last;
|
||||
};
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef MOVEGEN_H_INCLUDED
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "movepick.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace {
|
||||
|
||||
enum Stages {
|
||||
|
@ -263,3 +265,5 @@ top:
|
|||
assert(false);
|
||||
return MOVE_NONE; // Silence warning
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#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
|
||||
|
@ -156,4 +158,6 @@ private:
|
|||
ExtMove moves[MAX_MOVES];
|
||||
};
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef MOVEPICK_H_INCLUDED
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#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<
|
||||
|
@ -49,6 +49,6 @@ using OutputLayer = AffineTransform<HiddenLayer2, 1>;
|
|||
|
||||
using Network = Layers::OutputLayer;
|
||||
|
||||
} // namespace Eval::NNUE
|
||||
} // namespace Stockfish::Eval::NNUE
|
||||
|
||||
#endif // #ifndef NNUE_HALFKP_256X2_32_32_H_INCLUDED
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include "evaluate_nnue.h"
|
||||
|
||||
namespace Eval::NNUE {
|
||||
namespace Stockfish::Eval::NNUE {
|
||||
|
||||
// Input feature converter
|
||||
LargePagePtr<FeatureTransformer> feature_transformer;
|
||||
|
@ -141,4 +141,4 @@ namespace Eval::NNUE {
|
|||
return ReadParameters(stream);
|
||||
}
|
||||
|
||||
} // namespace Eval::NNUE
|
||||
} // namespace Stockfish::Eval::NNUE
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
namespace Eval::NNUE {
|
||||
namespace Stockfish::Eval::NNUE {
|
||||
|
||||
// Hash value of evaluation function structure
|
||||
constexpr std::uint32_t kHashValue =
|
||||
|
@ -54,6 +54,6 @@ namespace Eval::NNUE {
|
|||
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
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#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>
|
||||
|
@ -64,6 +64,6 @@ namespace Eval::NNUE::Features {
|
|||
|
||||
};
|
||||
|
||||
} // namespace Eval::NNUE::Features
|
||||
} // namespace Stockfish::Eval::NNUE::Features
|
||||
|
||||
#endif // #ifndef NNUE_FEATURE_SET_H_INCLUDED
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "../../evaluate.h"
|
||||
#include "../nnue_common.h"
|
||||
|
||||
namespace Eval::NNUE::Features {
|
||||
namespace Stockfish::Eval::NNUE::Features {
|
||||
|
||||
class IndexList;
|
||||
|
||||
|
@ -40,6 +40,6 @@ namespace Eval::NNUE::Features {
|
|||
kFriend // side to move
|
||||
};
|
||||
|
||||
} // namespace Eval::NNUE::Features
|
||||
} // namespace Stockfish::Eval::NNUE::Features
|
||||
|
||||
#endif // #ifndef NNUE_FEATURES_COMMON_H_INCLUDED
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#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) {
|
||||
|
@ -65,4 +65,4 @@ namespace Eval::NNUE::Features {
|
|||
|
||||
template class HalfKP<Side::kFriend>;
|
||||
|
||||
} // namespace Eval::NNUE::Features
|
||||
} // namespace Stockfish::Eval::NNUE::Features
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#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
|
||||
|
@ -54,6 +54,6 @@ namespace Eval::NNUE::Features {
|
|||
IndexList* removed, IndexList* added);
|
||||
};
|
||||
|
||||
} // namespace Eval::NNUE::Features
|
||||
} // namespace Stockfish::Eval::NNUE::Features
|
||||
|
||||
#endif // #ifndef NNUE_FEATURES_HALF_KP_H_INCLUDED
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#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>
|
||||
|
@ -59,6 +59,6 @@ namespace Eval::NNUE::Features {
|
|||
: public ValueList<IndexType, RawFeatures::kMaxActiveDimensions> {
|
||||
};
|
||||
|
||||
} // namespace Eval::NNUE::Features
|
||||
} // namespace Stockfish::Eval::NNUE::Features
|
||||
|
||||
#endif // NNUE_FEATURES_INDEX_LIST_H_INCLUDED
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <iostream>
|
||||
#include "../nnue_common.h"
|
||||
|
||||
namespace Eval::NNUE::Layers {
|
||||
namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
// Affine transformation layer
|
||||
template <typename PreviousLayer, IndexType OutputDimensions>
|
||||
|
@ -459,6 +459,6 @@ namespace Eval::NNUE::Layers {
|
|||
#endif
|
||||
};
|
||||
|
||||
} // namespace Eval::NNUE::Layers
|
||||
} // namespace Stockfish::Eval::NNUE::Layers
|
||||
|
||||
#endif // #ifndef NNUE_LAYERS_AFFINE_TRANSFORM_H_INCLUDED
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "../nnue_common.h"
|
||||
|
||||
namespace Eval::NNUE::Layers {
|
||||
namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
// Clipped ReLU
|
||||
template <typename PreviousLayer>
|
||||
|
@ -161,6 +161,6 @@ namespace Eval::NNUE::Layers {
|
|||
PreviousLayer previous_layer_;
|
||||
};
|
||||
|
||||
} // namespace Eval::NNUE::Layers
|
||||
} // namespace Stockfish::Eval::NNUE::Layers
|
||||
|
||||
#endif // NNUE_LAYERS_CLIPPED_RELU_H_INCLUDED
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "../nnue_common.h"
|
||||
|
||||
namespace Eval::NNUE::Layers {
|
||||
namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
// Input layer
|
||||
template <IndexType OutputDimensions, IndexType Offset = 0>
|
||||
|
@ -63,6 +63,6 @@ class InputSlice {
|
|||
private:
|
||||
};
|
||||
|
||||
} // namespace Layers
|
||||
} // namespace Stockfish::Eval::NNUE::Layers
|
||||
|
||||
#endif // #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#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 };
|
||||
|
@ -35,6 +35,6 @@ namespace Eval::NNUE {
|
|||
AccumulatorState state[2];
|
||||
};
|
||||
|
||||
} // namespace Eval::NNUE
|
||||
} // namespace Stockfish::Eval::NNUE
|
||||
|
||||
#endif // NNUE_ACCUMULATOR_H_INCLUDED
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
// 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, "");
|
||||
|
@ -33,6 +33,6 @@ namespace Eval::NNUE {
|
|||
// 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
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
namespace Eval::NNUE {
|
||||
namespace Stockfish::Eval::NNUE {
|
||||
|
||||
// Version of the evaluation file
|
||||
constexpr std::uint32_t kVersion = 0x7AF32F16u;
|
||||
|
@ -127,6 +127,6 @@ namespace Eval::NNUE {
|
|||
return result;
|
||||
}
|
||||
|
||||
} // namespace Eval::NNUE
|
||||
} // namespace Stockfish::Eval::NNUE
|
||||
|
||||
#endif // #ifndef NNUE_COMMON_H_INCLUDED
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#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
|
||||
|
@ -412,6 +412,6 @@ namespace Eval::NNUE {
|
|||
WeightType weights_[kHalfDimensions * kInputDimensions];
|
||||
};
|
||||
|
||||
} // namespace Eval::NNUE
|
||||
} // namespace Stockfish::Eval::NNUE
|
||||
|
||||
#endif // #ifndef NNUE_FEATURE_TRANSFORMER_H_INCLUDED
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "position.h"
|
||||
#include "thread.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace {
|
||||
|
||||
#define V Value
|
||||
|
@ -298,3 +300,5 @@ template Score Entry::do_king_safety<WHITE>(const Position& pos);
|
|||
template Score Entry::do_king_safety<BLACK>(const Position& pos);
|
||||
|
||||
} // namespace Pawns
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#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
|
||||
|
@ -65,6 +65,6 @@ typedef HashTable<Entry, 131072> Table;
|
|||
|
||||
Entry* probe(const Position& pos);
|
||||
|
||||
} // namespace Pawns
|
||||
} // namespace Stockfish::Pawns
|
||||
|
||||
#endif // #ifndef PAWNS_H_INCLUDED
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
using std::string;
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace Zobrist {
|
||||
|
||||
Key psq[PIECE_NB][SQUARE_NB];
|
||||
|
@ -1338,3 +1340,5 @@ bool Position::pos_is_ok() const {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#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
|
||||
|
@ -423,4 +424,6 @@ inline StateInfo* Position::state() const {
|
|||
return st;
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef POSITION_H_INCLUDED
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "bitboard.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -126,3 +127,5 @@ void init() {
|
|||
}
|
||||
|
||||
} // namespace PSQT
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "types.h"
|
||||
|
||||
|
||||
namespace PSQT
|
||||
namespace Stockfish::PSQT
|
||||
{
|
||||
|
||||
extern Score psq[PIECE_NB][SQUARE_NB];
|
||||
|
@ -32,7 +32,7 @@ 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
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include "uci.h"
|
||||
#include "syzygy/tbprobe.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace Search {
|
||||
|
||||
LimitsType Limits;
|
||||
|
@ -422,7 +424,7 @@ void Thread::search() {
|
|||
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
|
||||
|
@ -2034,3 +2036,5 @@ void Tablebases::rank_root_moves(Position& pos, Search::RootMoves& rootMoves) {
|
|||
m.tbRank = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "movepick.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
class Position;
|
||||
|
||||
namespace Search {
|
||||
|
@ -107,4 +109,6 @@ void clear();
|
|||
|
||||
} // namespace Search
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef SEARCH_H_INCLUDED
|
||||
|
|
|
@ -50,9 +50,11 @@
|
|||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
using namespace Tablebases;
|
||||
using namespace Stockfish::Tablebases;
|
||||
|
||||
int Tablebases::MaxCardinality;
|
||||
int Stockfish::Tablebases::MaxCardinality;
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -1610,3 +1612,5 @@ bool Tablebases::root_probe_wdl(Position& pos, Search::RootMoves& rootMoves) {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "../search.h"
|
||||
|
||||
namespace Tablebases {
|
||||
namespace Stockfish::Tablebases {
|
||||
|
||||
enum WDLScore {
|
||||
WDLLoss = -2, // Loss
|
||||
|
@ -73,6 +73,6 @@ inline std::ostream& operator<<(std::ostream& os, const ProbeState v) {
|
|||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Stockfish::Tablebases
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "syzygy/tbprobe.h"
|
||||
#include "tt.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
ThreadPool Threads; // Global object
|
||||
|
||||
|
||||
|
@ -258,3 +260,5 @@ void ThreadPool::wait_for_search_finished() const {
|
|||
if (th != front())
|
||||
th->wait_for_search_finished();
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#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
|
||||
|
@ -128,4 +129,6 @@ private:
|
|||
|
||||
extern ThreadPool Threads;
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef THREAD_H_INCLUDED
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#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::*)()>>
|
||||
|
@ -57,10 +59,16 @@ public:
|
|||
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
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "timeman.h"
|
||||
#include "uci.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
TimeManagement Time; // Our global time management object
|
||||
|
||||
|
||||
|
@ -95,3 +97,5 @@ void TimeManagement::init(Search::LimitsType& limits, Color us, int ply) {
|
|||
if (Options["Ponder"])
|
||||
optimumTime += optimumTime / 4;
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#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.
|
||||
|
||||
|
@ -44,4 +46,6 @@ private:
|
|||
|
||||
extern TimeManagement Time;
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef TIMEMAN_H_INCLUDED
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#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
|
||||
|
@ -156,3 +158,5 @@ int TranspositionTable::hashfull() const {
|
|||
|
||||
return cnt / ClusterSize;
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
4
src/tt.h
4
src/tt.h
|
@ -22,6 +22,8 @@
|
|||
#include "misc.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
/// TTEntry struct is the 10 bytes transposition table entry, defined as below:
|
||||
///
|
||||
/// key 16 bit
|
||||
|
@ -100,4 +102,6 @@ private:
|
|||
|
||||
extern TranspositionTable TT;
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef TT_H_INCLUDED
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
using std::string;
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
bool Tune::update_on_last;
|
||||
const UCI::Option* LastOption = nullptr;
|
||||
BoolConditions Conditions;
|
||||
|
@ -126,6 +128,8 @@ void BoolConditions::set() {
|
|||
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.
|
||||
|
@ -138,7 +142,11 @@ void BoolConditions::set() {
|
|||
|
||||
#include <cmath>
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
void Tune::read_results() {
|
||||
|
||||
/* ...insert your values here... */
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
typedef std::pair<int, int> Range; // Option's min-max values
|
||||
typedef Range (RangeFun) (int);
|
||||
|
||||
|
@ -190,4 +192,6 @@ public:
|
|||
#define TUNE_CONDITIONS() int UNIQUE(c, __LINE__) = (Conditions.init(__COUNTER__), 0); \
|
||||
TUNE(Conditions, set_conditions)
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef TUNE_H_INCLUDED
|
||||
|
|
|
@ -83,6 +83,8 @@
|
|||
# define pext(b, m) 0
|
||||
#endif
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
#ifdef USE_POPCNT
|
||||
constexpr bool HasPopCnt = true;
|
||||
#else
|
||||
|
@ -482,6 +484,8 @@ constexpr Key make_key(uint64_t seed) {
|
|||
return seed * 6364136223846793005ULL + 1442695040888963407ULL;
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef TYPES_H_INCLUDED
|
||||
|
||||
#include "tune.h" // Global visibility to tuning setup
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
extern vector<string> setup_bench(const Position&, istream&);
|
||||
|
||||
namespace {
|
||||
|
@ -369,3 +371,5 @@ Move UCI::to_move(const Position& pos, string& str) {
|
|||
|
||||
return MOVE_NONE;
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
class Position;
|
||||
|
||||
namespace UCI {
|
||||
|
@ -78,4 +80,6 @@ Move to_move(const Position& pos, std::string& str);
|
|||
|
||||
extern UCI::OptionsMap Options;
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef UCI_H_INCLUDED
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
using std::string;
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
UCI::OptionsMap Options; // Global object
|
||||
|
||||
namespace UCI {
|
||||
|
@ -190,3 +192,5 @@ Option& Option::operator=(const string& v) {
|
|||
}
|
||||
|
||||
} // namespace UCI
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -39,16 +39,16 @@ case $1 in
|
|||
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: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:TranspositionTable::probe
|
||||
race:TranspositionTable::hashfull
|
||||
race:Stockfish::TranspositionTable::probe
|
||||
race:Stockfish::TranspositionTable::hashfull
|
||||
|
||||
EOF
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue