#include <string>
#include "evaluate.h"
-#include "misc.h"
#include "position.h"
#include "search.h"
#include "thread.h"
using namespace std;
-extern void benchmark(istringstream& is);
+extern void benchmark(const Position& pos, istream& is);
namespace {
void set_option(istringstream& up);
void set_position(Position& pos, istringstream& up);
void go(Position& pos, istringstream& up);
- void perft(Position& pos, istringstream& up);
}
void uci_loop(const string& args) {
- Position pos(StartFEN, false, 0); // The root position
+ Position pos(StartFEN, false, Threads.main_thread()); // The root position
string cmd, token;
while (token != "quit")
if (Search::Signals.stopOnPonderhit)
{
Search::Signals.stop = true;
- Threads.wait_for_search_finished(); // Wake up if is sleeping
+ Threads.main_thread()->wake_up(); // Could be sleeping
}
}
else if (token == "setoption")
set_option(is);
- else if (token == "perft")
- perft(pos, is);
-
else if (token == "d")
pos.print();
cout << Eval::trace(pos) << endl;
else if (token == "bench")
- benchmark(is);
+ benchmark(pos, is);
else if (token == "key")
cout << "key: " << hex << pos.key()
cout << "id name " << engine_info(true)
<< "\n" << Options
<< "\nuciok" << endl;
+
+ else if (token == "perft" && (is >> token)) // Read depth
+ {
+ stringstream ss;
+
+ ss << Options["Hash"] << " "
+ << Options["Threads"] << " " << token << " current perft";
+
+ benchmark(pos, ss);
+ }
+
else
cout << "Unknown command: " << cmd << endl;
else
return;
- pos.from_fen(fen, Options["UCI_Chess960"]);
+ pos.from_fen(fen, Options["UCI_Chess960"], Threads.main_thread());
// Parse move list (if any)
while (is >> token && (m = move_from_uci(pos, token)) != MOVE_NONE)
Threads.start_searching(pos, limits, searchMoves);
}
-
-
- // perft() is called when engine receives the "perft" command. The function
- // calls perft() with the required search depth then prints counted leaf nodes
- // and elapsed time.
-
- void perft(Position& pos, istringstream& is) {
-
- int depth;
-
- if (!(is >> depth))
- return;
-
- Time time = Time::current_time();
-
- int64_t n = Search::perft(pos, depth * ONE_PLY);
-
- int e = time.elapsed();
-
- cout << "\nNodes " << n
- << "\nTime (ms) " << e
- << "\nNodes/second " << int(n / (e / 1000.0)) << endl;
- }
}