From: ianfab Date: Sat, 11 Aug 2018 19:26:25 +0000 (+0200) Subject: Add benchmark support for variants X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=382034457b200114a1e7abdf86e815f49e6d5447;p=fairystockfish.git Add benchmark support for variants Use e.g. "bench crazyhouse" to run bench test for variants. --- diff --git a/src/benchmark.cpp b/src/benchmark.cpp index 1c69dca..43fe8fb 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -24,6 +24,7 @@ #include #include "position.h" +#include "uci.h" using namespace std; @@ -104,7 +105,21 @@ const vector Defaults = { vector setup_bench(const Position& current, istream& is) { vector fens, list; - string go, token; + string go, token, varname; + + streampos args = is.tellg(); + // Check whether the next token is a variant name + if ((is >> token) && variants.find(token) != variants.end()) + { + args = is.tellg(); + varname = token; + } + else + { + is.seekg(args); + varname = string(Options["UCI_Variant"]); + } + const Variant* variant = variants.find(varname)->second; // Assign default values to missing arguments string ttSize = (is >> token) ? token : "16"; @@ -116,7 +131,12 @@ vector setup_bench(const Position& current, istream& is) { go = "go " + limitType + " " + limit; if (fenFile == "default") - fens = Defaults; + { + if (varname != "chess") + fens.push_back(variant->startFen); + else + fens = Defaults; + } else if (fenFile == "current") fens.push_back(current.fen()); @@ -142,6 +162,7 @@ vector setup_bench(const Position& current, istream& is) { list.emplace_back("ucinewgame"); list.emplace_back("setoption name Threads value " + threads); list.emplace_back("setoption name Hash value " + ttSize); + list.emplace_back("setoption name UCI_Variant value " + varname); for (const string& fen : fens) if (fen.find("setoption") != string::npos)