- for(i = 0; i < 15; i++) {
- pos.from_fen(BenchmarkPositions[i]);
- think(pos, true, false, 0, 0, 0, 0, 0, 60000, moves);
+ csVal >> val;
+ csVal >> fileName;
+ csVal >> limitType;
+ csVal >> timFile;
+
+ secsPerPos = maxDepth = maxNodes = 0;
+
+ if (limitType == "time")
+ secsPerPos = val * 1000;
+ else if (limitType == "depth" || limitType == "perft")
+ maxDepth = val;
+ else
+ maxNodes = val;
+
+ vector<string> positions;
+
+ if (fileName != "default")
+ {
+ ifstream fenFile(fileName.c_str());
+ if (!fenFile.is_open())
+ {
+ cerr << "Unable to open positions file " << fileName << endl;
+ Application::exit_with_failure();
+ }
+ string pos;
+ while (fenFile.good())
+ {
+ getline(fenFile, pos);
+ if (!pos.empty())
+ positions.push_back(pos);
+ }
+ fenFile.close();
+ } else
+ for (int i = 0; i < 16; i++)
+ positions.push_back(string(BenchmarkPositions[i]));
+
+ ofstream timingFile;
+ if (!timFile.empty())
+ {
+ timingFile.open(timFile.c_str(), ios::out | ios::app);
+ if (!timingFile.is_open())
+ {
+ cerr << "Unable to open timing file " << timFile << endl;
+ Application::exit_with_failure();
+ }
+ }
+
+ vector<string>::iterator it;
+ int cnt = 1;
+ int64_t totalNodes = 0;
+ int startTime = get_system_time();
+
+ for (it = positions.begin(); it != positions.end(); ++it, ++cnt)
+ {
+ Move moves[1] = {MOVE_NONE};
+ int dummy[2] = {0, 0};
+ Position pos(*it, 0);
+ cerr << "\nBench position: " << cnt << '/' << positions.size() << endl << endl;
+ if (limitType == "perft")
+ {
+ int64_t perftCnt = perft(pos, maxDepth * ONE_PLY);
+ cerr << "\nPerft " << maxDepth << " result (nodes searched): " << perftCnt << endl << endl;
+ totalNodes += perftCnt;
+ } else {
+ if (!think(pos, false, false, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves))
+ break;
+ totalNodes += nodes_searched();
+ }