1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Let benchmark to default to depth 12

And also simplify a lot the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-11-08 11:08:01 +01:00
parent d2d953713f
commit fad595f5b6
2 changed files with 22 additions and 59 deletions

View file

@ -35,7 +35,7 @@ using namespace std;
//// Variables
////
const string BenchmarkPositions[] = {
static const string BenchmarkPositions[] = {
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -",
"8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -",
@ -69,53 +69,35 @@ const string BenchmarkPositions[] = {
void benchmark(const string& commandLine) {
istringstream csVal(commandLine);
istringstream csStr(commandLine);
string ttSize, threads, fileName, limitType, timFile;
vector<string> positions;
string ttSize, threads, limit, posFile, limitType;
int val, secsPerPos, maxDepth, maxNodes;
csStr >> ttSize;
csVal >> val;
if (val < 4 || val > 1024)
{
cerr << "The hash table size must be between 4 and 1024" << endl;
Application::exit_with_failure();
}
csStr >> threads;
csVal >> val;
if (val < 1 || val > MAX_THREADS)
{
cerr << "The number of threads must be between 1 and " << MAX_THREADS << endl;
Application::exit_with_failure();
}
csStr >> ttSize >> threads >> limit >> posFile >> limitType;
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");
csVal >> val;
csVal >> fileName;
csVal >> limitType;
csVal >> timFile;
secsPerPos = maxDepth = maxNodes = 0;
val = atoi(limit.c_str());
if (limitType == "time")
secsPerPos = val * 1000;
else if (limitType == "depth" || limitType == "perft")
if (limitType == "depth" || limitType == "perft")
maxDepth = val;
else if (limitType == "time")
secsPerPos = val * 1000;
else
maxNodes = val;
vector<string> positions;
if (fileName != "default")
if (posFile != "default")
{
ifstream fenFile(fileName.c_str());
ifstream fenFile(posFile.c_str());
if (!fenFile.is_open())
{
cerr << "Unable to open positions file " << fileName << endl;
cerr << "Unable to open positions file " << posFile << endl;
Application::exit_with_failure();
}
string pos;
@ -130,17 +112,6 @@ void benchmark(const string& commandLine) {
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;
@ -148,8 +119,8 @@ void benchmark(const string& commandLine) {
for (it = positions.begin(); it != positions.end(); ++it, ++cnt)
{
Move moves[1] = {MOVE_NONE};
int dummy[2] = {0, 0};
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")
@ -170,16 +141,10 @@ void benchmark(const string& commandLine) {
<< "\nNodes searched : " << totalNodes
<< "\nNodes/second : " << (int)(totalNodes/(cnt/1000.0)) << endl << endl;
if (!timFile.empty())
{
timingFile << cnt << endl << endl;
timingFile.close();
}
// Under MS Visual C++ debug window always unconditionally closes
// when program exits, this is bad because we want to read results before.
#if (defined(WINDOWS) || defined(WIN32) || defined(WIN64))
cerr << "Press any key to exit" << endl;
cin >> fileName;
cin >> ttSize;
#endif
}

View file

@ -71,18 +71,16 @@ int main(int argc, char *argv[]) {
}
else // Process command line arguments
{
if (string(argv[1]) != "bench" || argc < 4 || argc > 8)
if (string(argv[1]) != "bench" || argc < 4 || argc > 7)
cout << "Usage: stockfish bench <hash size> <threads> "
<< "[time = 60s] [fen positions file = default] "
<< "[time, depth, perft or node limited = time] "
<< "[timing file name = none]" << endl;
<< "[limit = 12] [fen positions file = default] "
<< "[depth, time, perft or node limited = depth]" << endl;
else
{
string time = argc > 4 ? argv[4] : "60";
string fen = argc > 5 ? argv[5] : "default";
string lim = argc > 6 ? argv[6] : "time";
string tim = argc > 7 ? argv[7] : "";
benchmark(string(argv[2]) + " " + string(argv[3]) + " " + time + " " + fen + " " + lim + " " + tim);
string val = argc > 4 ? argv[4] : "12";
string fen = argc > 5 ? argv[5] : "default";
string lim = argc > 6 ? argv[6] : "depth";
benchmark(string(argv[2]) + " " + string(argv[3]) + " " + val + " " + fen + " " + lim);
}
}