summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
cc04a74)
Now that we can call bench on current position
we can directly use it to perform our perft.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
#include <fstream>
#include <iostream>
#include <fstream>
#include <iostream>
#include <vector>
#include "misc.h"
#include <vector>
#include "misc.h"
/// format (defaults are the positions defined above) and the type of the
/// limit value: depth (default), time in secs or number of nodes.
/// format (defaults are the positions defined above) and the type of the
/// limit value: depth (default), time in secs or number of nodes.
-void benchmark(istringstream& is) {
+void benchmark(const Position& current, istream& is) {
string token;
Search::LimitsType limits;
string token;
Search::LimitsType limits;
- vector<string> fens(Defaults, Defaults + 16);
// Assign default values to missing arguments
string ttSize = (is >> token) ? token : "128";
// Assign default values to missing arguments
string ttSize = (is >> token) ? token : "128";
else
limits.depth = atoi(limit.c_str());
else
limits.depth = atoi(limit.c_str());
- if (fenFile == "current")
- {
- fens.clear();
- fens.push_back(Search::RootPosition.to_fen());
- }
- else if (fenFile != "default")
+ if (fenFile == "default")
+ fens.assign(Defaults, Defaults + 16);
+
+ else if (fenFile == "current")
+ fens.push_back(current.to_fen());
+
+ else
string fen;
ifstream file(fenFile.c_str());
string fen;
ifstream file(fenFile.c_str());
#include <string>
#include "evaluate.h"
#include <string>
#include "evaluate.h"
#include "position.h"
#include "search.h"
#include "thread.h"
#include "position.h"
#include "search.h"
#include "thread.h"
-extern void benchmark(istringstream& is);
+extern void benchmark(const Position& pos, istream& is);
void set_option(istringstream& up);
void set_position(Position& pos, istringstream& up);
void go(Position& pos, istringstream& up);
void set_option(istringstream& up);
void set_position(Position& pos, istringstream& up);
void go(Position& pos, istringstream& up);
- void perft(Position& pos, istringstream& up);
Position pos(StartFEN, false, Threads.main_thread()); // The root position
string cmd, token;
Position pos(StartFEN, false, Threads.main_thread()); // The root position
string cmd, token;
- Search::RootPosition = pos;
-
while (token != "quit")
{
if (!args.empty())
while (token != "quit")
{
if (!args.empty())
else if (token == "setoption")
set_option(is);
else if (token == "setoption")
set_option(is);
- else if (token == "perft")
- perft(pos, is);
-
else if (token == "d")
pos.print();
else if (token == "d")
pos.print();
cout << Eval::trace(pos) << endl;
else if (token == "bench")
cout << Eval::trace(pos) << endl;
else if (token == "bench")
else if (token == "key")
cout << "key: " << hex << pos.key()
else if (token == "key")
cout << "key: " << hex << pos.key()
cout << "id name " << engine_info(true)
<< "\n" << Options
<< "\nuciok" << endl;
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
cout << "Unknown command: " << cmd << endl;
Threads.start_searching(pos, limits, searchMoves);
}
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;
- }