Skip to content

Commit 7ffae17

Browse files
ddobbelaerevondele
authored andcommitted
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 #3370 No functional change.
1 parent 9b1274a commit 7ffae17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+200
-58
lines changed

src/benchmark.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ const vector<string> Defaults = {
9292

9393
} // namespace
9494

95+
namespace Stockfish {
96+
9597
/// setup_bench() builds a list of UCI commands to be run by bench. There
9698
/// are five parameters: TT size in MB, number of search threads that
9799
/// 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) {
168170

169171
return list;
170172
}
173+
174+
} // namespace Stockfish

src/bitbase.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "bitboard.h"
2424
#include "types.h"
2525

26+
namespace Stockfish {
27+
2628
namespace {
2729

2830
// There are 24 possible pawn squares: files A to D and ranks from 2 to 7.
@@ -66,7 +68,6 @@ namespace {
6668

6769
} // namespace
6870

69-
7071
bool Bitbases::probe(Square wksq, Square wpsq, Square bksq, Color stm) {
7172

7273
assert(file_of(wpsq) <= FILE_D);
@@ -96,7 +97,6 @@ void Bitbases::init() {
9697
KPKBitbase.set(idx);
9798
}
9899

99-
100100
namespace {
101101

102102
KPKPosition::KPKPosition(unsigned idx) {
@@ -168,3 +168,5 @@ namespace {
168168
}
169169

170170
} // namespace
171+
172+
} // namespace Stockfish

src/bitboard.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "bitboard.h"
2323
#include "misc.h"
2424

25+
namespace Stockfish {
26+
2527
uint8_t PopCnt16[1 << 16];
2628
uint8_t SquareDistance[SQUARE_NB][SQUARE_NB];
2729

@@ -42,7 +44,6 @@ namespace {
4244

4345
}
4446

45-
4647
/// safe_destination() returns the bitboard of target square for the given step
4748
/// from the given square. If the step is off the board, returns empty bitboard.
4849

@@ -111,7 +112,6 @@ void Bitboards::init() {
111112
}
112113
}
113114

114-
115115
namespace {
116116

117117
Bitboard sliding_attack(PieceType pt, Square sq, Bitboard occupied) {
@@ -211,3 +211,5 @@ namespace {
211211
}
212212
}
213213
}
214+
215+
} // namespace Stockfish

src/bitboard.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@
2323

2424
#include "types.h"
2525

26+
namespace Stockfish {
27+
2628
namespace Bitbases {
2729

2830
void init();
2931
bool probe(Square wksq, Square wpsq, Square bksq, Color us);
3032

31-
}
33+
} // namespace Stockfish::Bitbases
3234

3335
namespace Bitboards {
3436

3537
void init();
3638
std::string pretty(Bitboard b);
3739

38-
}
40+
} // namespace Stockfish::Bitboards
3941

4042
constexpr Bitboard AllSquares = ~Bitboard(0);
4143
constexpr Bitboard DarkSquares = 0xAA55AA55AA55AA55ULL;
@@ -430,4 +432,6 @@ inline Square frontmost_sq(Color c, Bitboard b) {
430432
return c == WHITE ? msb(b) : lsb(b);
431433
}
432434

435+
} // namespace Stockfish
436+
433437
#endif // #ifndef BITBOARD_H_INCLUDED

src/endgame.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "endgame.h"
2323
#include "movegen.h"
2424

25+
namespace Stockfish {
26+
2527
namespace {
2628

2729
// Used to drive the king towards the edge of the board
@@ -741,3 +743,5 @@ ScaleFactor Endgame<KPKP>::operator()(const Position& pos) const {
741743
// it's probably at least a draw even with the pawn.
742744
return Bitbases::probe(strongKing, strongPawn, weakKing, us) ? SCALE_FACTOR_NONE : SCALE_FACTOR_DRAW;
743745
}
746+
747+
} // namespace Stockfish

src/endgame.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "position.h"
2929
#include "types.h"
3030

31+
namespace Stockfish {
3132

3233
/// EndgameCode lists all supported endgame functions by corresponding codes
3334

@@ -120,4 +121,6 @@ namespace Endgames {
120121
}
121122
}
122123

124+
} // namespace Stockfish
125+
123126
#endif // #ifndef ENDGAME_H_INCLUDED

src/evaluate.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454

5555

5656
using namespace std;
57-
using namespace Eval::NNUE;
57+
using namespace Stockfish::Eval::NNUE;
58+
59+
namespace Stockfish {
5860

5961
namespace Eval {
6062

@@ -1146,3 +1148,5 @@ std::string Eval::trace(const Position& pos) {
11461148

11471149
return ss.str();
11481150
}
1151+
1152+
} // namespace Stockfish

src/evaluate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include "types.h"
2525

26+
namespace Stockfish {
27+
2628
class Position;
2729

2830
namespace Eval {
@@ -49,4 +51,6 @@ namespace Eval {
4951

5052
} // namespace Eval
5153

54+
} // namespace Stockfish
55+
5256
#endif // #ifndef EVALUATE_H_INCLUDED

src/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "tt.h"
2929
#include "uci.h"
3030

31+
using namespace Stockfish;
32+
3133
int main(int argc, char* argv[]) {
3234

3335
std::cout << engine_info() << std::endl;

src/material.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
using namespace std;
2626

27+
namespace Stockfish {
28+
2729
namespace {
2830
#define S(mg, eg) make_score(mg, eg)
2931

@@ -223,3 +225,5 @@ Entry* probe(const Position& pos) {
223225
}
224226

225227
} // namespace Material
228+
229+
} // namespace Stockfish

0 commit comments

Comments
 (0)