当前位置: 首页>>代码示例>>C++>>正文


C++ Simulator::benchmark方法代码示例

本文整理汇总了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();
}
开发者ID:int3,项目名称:acaiberry,代码行数:77,代码来源:main.cpp


注:本文中的Simulator::benchmark方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。