mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Restore NPS output for Perft
Previously it was possible to also get the node counter after running a bench with perft, i.e. `./stockfish bench 1 1 5 current perft`, caused by a small regression from the uci refactoring. ``` Nodes searched: 4865609 =========================== Total time (ms) : 18 Nodes searched : 4865609 Nodes/second : 270311611 ```` closes https://github.com/official-stockfish/Stockfish/pull/5188 No functional change
This commit is contained in:
parent
d47aa639bd
commit
ddd250b9d6
7 changed files with 45 additions and 20 deletions
|
@ -93,7 +93,7 @@ const std::vector<std::string> Defaults = {
|
|||
|
||||
} // 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
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Stockfish {
|
||||
namespace Stockfish::Benchmark {
|
||||
|
||||
std::vector<std::string> setup_bench(const std::string&, std::istream&);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <iosfwd>
|
||||
#include <cassert>
|
||||
|
||||
#include "evaluate.h"
|
||||
#include "misc.h"
|
||||
|
@ -54,15 +55,16 @@ Engine::Engine(std::string path) :
|
|||
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);
|
||||
}
|
||||
void Engine::stop() { threads.stop = true; }
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#include "nnue/network.h"
|
||||
#include "position.h"
|
||||
|
@ -33,6 +34,7 @@
|
|||
#include "thread.h"
|
||||
#include "tt.h"
|
||||
#include "ucioption.h"
|
||||
#include "syzygy/tbprobe.h" // for Stockfish::Depth
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
|
@ -45,6 +47,8 @@ class Engine {
|
|||
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
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#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.
|
||||
|
@ -56,13 +56,12 @@ uint64_t perft(Position& pos, Depth depth) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
22
src/uci.cpp
22
src/uci.cpp
|
@ -219,6 +219,10 @@ Search::LimitsType UCIEngine::parse_limits(std::istream& is) {
|
|||
void UCIEngine::go(std::istringstream& is) {
|
||||
|
||||
Search::LimitsType limits = parse_limits(is);
|
||||
|
||||
if (limits.perft)
|
||||
perft(limits);
|
||||
else
|
||||
engine.go(limits);
|
||||
}
|
||||
|
||||
|
@ -233,7 +237,7 @@ 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; });
|
||||
|
@ -251,8 +255,16 @@ void UCIEngine::bench(std::istream& args) {
|
|||
<< std::endl;
|
||||
if (token == "go")
|
||||
{
|
||||
go(is);
|
||||
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;
|
||||
}
|
||||
|
@ -288,6 +300,12 @@ void UCIEngine::setoption(std::istringstream& is) {
|
|||
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;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <cstdint>
|
||||
|
||||
#include "engine.h"
|
||||
#include "misc.h"
|
||||
|
@ -61,6 +62,7 @@ class UCIEngine {
|
|||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue