本文整理汇总了C++中Simulator::benchmark方法的典型用法代码示例。如果您正苦于以下问题:C++ Simulator::benchmark方法的具体用法?C++ Simulator::benchmark怎么用?C++ Simulator::benchmark使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simulator
的用法示例。
在下文中一共展示了Simulator::benchmark方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char* argv[]) {
QApplication app(argc, argv);
qRegisterMetaType<MoveInfo>("MoveInfo");
qRegisterMetaType<PassInfo>("PassInfo");
Dict dict;
if (!dict.load("resource/dawg.bin") && !dict.load("/usr/local/share/AcaiBerry/resource/dawg.bin")) {
cout << "Could not find dawg.bin in ./resource/ or /usr/local/share/AcaiBerry/resource.\n";
return 1;
}
GameCore gc(dict);
string usage(
"AcaiBerry -- A Scrabble Program.\n"
"Usage:\n"
"[no arguments] Run the game.\n"
"--help Display this message.\n"
"--benchmark [num] Simulate [num] games between 2 AI players. No GUI display.\n"
"--me-first Run the game with you making the first move.\n"
"--demo Run a game between 2 AI players and see the result.\n"
"--text Run in text mode. (Not fully implemented; only works together with --demo.)\n"
);
QStringList args = app.arguments();
bool meFirst = false;
bool demo = false;
bool textMode = false;
try {
for (int i=0; i<args.length(); i++) {
if (args[i] == "--help") {
cout << usage;
return 0;
} else if (args[i] == "--benchmark") {
i++;
if (i >= args.length())
throw OptionError();
bool conversionOk;
int numGames = args[i].toInt(&conversionOk);
if (!conversionOk)
throw OptionError();
Simulator sim (gc, dict);
sim.benchmark(numGames);
return 0;
} else if (args[i] == "--demo") {
demo = true;
} else if (args[i] == "--me-first") {
meFirst = true;
} else if (args[i] == "--text") {
textMode = true;
}
}
} catch(OptionError& e) {
cout << usage;
return 0;
}
QWidget win;
setupWindow(win, gc, meFirst ? 0 : 1);
gc.reset();
if (demo) {
Simulator sim (gc, dict);
sim.benchmark(1);
if (textMode) {
cout << txtDisplay(gc.board());
return 0;
} else {
return app.exec();
}
}
Berry berry (gc.pin(meFirst ? 1 : 0), gc.board(), dict);
if (!meFirst)
berry.makeTurn();
return app.exec();
}