mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 09:06:45 +08:00
Process 'bench' also from SF prompt
It is possible to start with 'stockfish', then from command prompt type 'bench' and SF will do what you expect. Old behaviour is anyhow preserved. As a bonus we can now start from command line any UCI command understood by Stockfish. The difference is that after execution of a command from arguments SF quits, while at the end of the same command from prompt SF stays in UCI loop. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
18
src/uci.cpp
18
src/uci.cpp
@@ -30,6 +30,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern void benchmark(istringstream& is);
|
||||
|
||||
namespace {
|
||||
|
||||
// FEN string of the initial position, normal chess
|
||||
@@ -52,14 +54,17 @@ namespace {
|
||||
/// that we exit gracefully if the GUI dies unexpectedly. In addition to the UCI
|
||||
/// commands, the function also supports a few debug commands.
|
||||
|
||||
void uci_loop() {
|
||||
void uci_loop(const string& args) {
|
||||
|
||||
Position pos(StartFEN, false, 0); // The root position
|
||||
string cmd, token;
|
||||
|
||||
while (token != "quit")
|
||||
{
|
||||
if (!getline(cin, cmd)) // Block here waiting for input
|
||||
if (!args.empty())
|
||||
cmd = args;
|
||||
|
||||
else if (!getline(cin, cmd)) // Block here waiting for input
|
||||
cmd = "quit";
|
||||
|
||||
istringstream is(cmd);
|
||||
@@ -113,6 +118,9 @@ void uci_loop() {
|
||||
else if (token == "eval")
|
||||
cout << Eval::trace(pos) << endl;
|
||||
|
||||
else if (token == "bench")
|
||||
benchmark(is);
|
||||
|
||||
else if (token == "key")
|
||||
cout << "key: " << hex << pos.key()
|
||||
<< "\nmaterial key: " << pos.material_key()
|
||||
@@ -124,6 +132,12 @@ void uci_loop() {
|
||||
<< "\nuciok" << endl;
|
||||
else
|
||||
cout << "Unknown command: " << cmd << endl;
|
||||
|
||||
if (!args.empty()) // Command line arguments have one-shot behaviour
|
||||
{
|
||||
Threads.wait_for_search_finished();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user