- i = atoi(threads.c_str());
- if(i < 1 || i > THREAD_MAX) {
- std::cerr << "The number of threads must be between 1 and " << THREAD_MAX
- << std::endl;
- exit(EXIT_FAILURE);
- }
-
- set_option_value("Hash", ttSize);
- set_option_value("Threads", threads);
- set_option_value("OwnBook", "false");
- set_option_value("Use Search Log", "true");
- set_option_value("Search Log Filename", "bench.txt");
-
- for(i = 0; i < 15; i++) {
- pos.from_fen(BenchmarkPositions[i]);
- think(pos, true, false, 0, 0, 0, 0, 0, 60000, moves);
+ ttSize = argc > 2 ? argv[2] : "128";
+ threads = argc > 3 ? argv[3] : "1";
+ valStr = argc > 4 ? argv[4] : "12";
+ posFile = argc > 5 ? argv[5] : "default";
+ valType = argc > 6 ? argv[6] : "depth";
+
+ Options["Hash"].set_value(ttSize);
+ Options["Threads"].set_value(threads);
+ Options["OwnBook"].set_value("false");
+ Options["Use Search Log"].set_value("true");
+ Options["Search Log Filename"].set_value("bench.txt");
+
+ secsPerPos = maxDepth = maxNodes = 0;
+ val = atoi(valStr.c_str());
+
+ if (valType == "depth" || valType == "perft")
+ maxDepth = val;
+ else if (valType == "time")
+ secsPerPos = val * 1000;
+ else
+ maxNodes = val;
+
+ if (posFile != "default")
+ {
+ ifstream fenFile(posFile.c_str());
+ if (!fenFile.is_open())
+ {
+ cerr << "Unable to open positions file " << posFile << endl;
+ exit(EXIT_FAILURE);
+ }
+ string pos;
+ while (fenFile.good())
+ {
+ getline(fenFile, pos);
+ if (!pos.empty())
+ positions.push_back(pos);
+ }
+ fenFile.close();
+ } else
+ for (int i = 0; !BenchmarkPositions[i].empty(); i++)
+ positions.push_back(BenchmarkPositions[i]);
+
+ 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, false, 0);
+ cerr << "\nBench position: " << cnt << '/' << positions.size() << endl << endl;
+ if (valType == "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 += pos.nodes_searched();
+ }