} // namespace
-namespace Stockfish {
+namespace Stockfish::Benchmark {
// Builds a list of UCI commands to be run by bench. There
// are five parameters: TT size in MB, number of search threads that
#include <string>
#include <vector>
-namespace Stockfish {
+namespace Stockfish::Benchmark {
std::vector<std::string> setup_bench(const std::string&, std::istream&);
#include <vector>
#include <sstream>
#include <iosfwd>
+#include <cassert>
#include "evaluate.h"
#include "misc.h"
pos.set(StartFEN, false, &states->back());
}
-void Engine::go(const Search::LimitsType& limits) {
+std::uint64_t Engine::perft(const std::string& fen, Depth depth, bool isChess960) {
verify_networks();
- if (limits.perft)
- {
- perft(pos.fen(), limits.perft, options["UCI_Chess960"]);
- return;
- }
+ return Benchmark::perft(fen, depth, isChess960);
+}
+
+void Engine::go(const Search::LimitsType& limits) {
+ assert(limits.perft == 0);
+ verify_networks();
threads.start_thinking(options, pos, states, limits);
}
#include <string_view>
#include <utility>
#include <vector>
+#include <cstdint>
#include "nnue/network.h"
#include "position.h"
#include "thread.h"
#include "tt.h"
#include "ucioption.h"
+#include "syzygy/tbprobe.h" // for Stockfish::Depth
namespace Stockfish {
Engine(std::string path = "");
~Engine() { wait_for_search_finished(); }
+ std::uint64_t perft(const std::string& fen, Depth depth, bool isChess960);
+
// non blocking call to start searching
void go(const Search::LimitsType&);
// non blocking call to stop searching
#include "types.h"
#include "uci.h"
-namespace Stockfish {
+namespace Stockfish::Benchmark {
// Utility to verify move generation. All the leaf nodes up
// to the given depth are generated and counted, and the sum is returned.
return nodes;
}
-inline void perft(const std::string& fen, Depth depth, bool isChess960) {
+inline uint64_t perft(const std::string& fen, Depth depth, bool isChess960) {
StateListPtr states(new std::deque<StateInfo>(1));
Position p;
p.set(fen, isChess960, &states->back());
- uint64_t nodes = perft<true>(p, depth);
- sync_cout << "\nNodes searched: " << nodes << "\n" << sync_endl;
+ return perft<true>(p, depth);
}
}
void UCIEngine::go(std::istringstream& is) {
Search::LimitsType limits = parse_limits(is);
- engine.go(limits);
+
+ if (limits.perft)
+ perft(limits);
+ else
+ engine.go(limits);
}
void UCIEngine::bench(std::istream& args) {
on_update_full(i, options["UCI_ShowWDL"]);
});
- std::vector<std::string> list = setup_bench(engine.fen(), args);
+ std::vector<std::string> list = Benchmark::setup_bench(engine.fen(), args);
num = count_if(list.begin(), list.end(),
[](const std::string& s) { return s.find("go ") == 0 || s.find("eval") == 0; });
<< std::endl;
if (token == "go")
{
- go(is);
- engine.wait_for_search_finished();
+ Search::LimitsType limits = parse_limits(is);
+
+ if (limits.perft)
+ nodes = perft(limits);
+ else
+ {
+ engine.go(limits);
+ engine.wait_for_search_finished();
+ }
+
nodes += nodesSearched;
nodesSearched = 0;
}
engine.get_options().setoption(is);
}
+std::uint64_t UCIEngine::perft(const Search::LimitsType& limits) {
+ auto nodes = engine.perft(engine.fen(), limits.perft, engine.get_options()["UCI_Chess960"]);
+ sync_cout << "\nNodes searched: " << nodes << "\n" << sync_endl;
+ return nodes;
+}
+
void UCIEngine::position(std::istringstream& is) {
std::string token, fen;
#include <iostream>
#include <string>
#include <string_view>
+#include <cstdint>
#include "engine.h"
#include "misc.h"
Engine engine;
CommandLine cli;
- void go(std::istringstream& is);
- void bench(std::istream& args);
- void position(std::istringstream& is);
- void setoption(std::istringstream& is);
+ void go(std::istringstream& is);
+ void bench(std::istream& args);
+ void position(std::istringstream& is);
+ void setoption(std::istringstream& is);
+ std::uint64_t perft(const Search::LimitsType&);
static void on_update_no_moves(const Engine::InfoShort& info);
static void on_update_full(const Engine::InfoFull& info, bool showWDL);