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


C++ GtpCommand类代码示例

本文整理汇总了C++中GtpCommand的典型用法代码示例。如果您正苦于以下问题:C++ GtpCommand类的具体用法?C++ GtpCommand怎么用?C++ GtpCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GtpCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CmdAnalyzeCommands

void RlEngine::CmdAnalyzeCommands(GtpCommand& cmd)
{
    GoGtpEngine::CmdAnalyzeCommands(cmd);
    m_commands.AddGoGuiAnalyzeCommands(cmd);
    string response = cmd.Response();
    cmd.SetResponse(GoGtpCommandUtil::SortResponseAnalyzeCommands(response));
}
开发者ID:muupan,项目名称:rlgo,代码行数:7,代码来源:RlEngine.cpp

示例2: CmdAnalyzeCommands

void FuegoTestEngine::CmdAnalyzeCommands(GtpCommand& cmd)
{
    GoGtpEngine::CmdAnalyzeCommands(cmd);
    m_extraCommands.AddGoGuiAnalyzeCommands(cmd);
    m_safetyCommands.AddGoGuiAnalyzeCommands(cmd);
    cmd <<
        "param/FuegoTest Param/fuegotest_param\n";
    string response = cmd.Response();
    cmd.SetResponse(GoGtpCommandUtil::SortResponseAnalyzeCommands(response));
}
开发者ID:Awilg,项目名称:fuego,代码行数:10,代码来源:FuegoTestEngine.cpp

示例3: CmdCompareFloat

/** Run another GTP command and compare its response against a float value.
    Arguments: float command [arg...] <br>
    Returns: -1 if response is smaller than float; 1 otherwise.
*/
void SgGtpCommands::CmdCompareFloat(GtpCommand& cmd)
{
    double value = cmd.FloatArg(0);
    string response = m_engine.ExecuteCommand(cmd.RemainingLine(0));
    istringstream in(response);
    double responseValue;
    in >> responseValue;
    if (! in)
        throw GtpFailure() << "response '" << response << "' is not a float";
    cmd << (responseValue < value ? "-1" : "1");
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例4: CmdSafe

/** List of safe points.
    If no color is given, safe points of both colors are listed.
    Arguments: benson|static [black|white]<br>
    Returns: number of point followed bu list of points in one line.
*/
void GoSafetyCommands::CmdSafe(GtpCommand& cmd)
{
    cmd.CheckNuArgLessEqual(2);
    string type = cmd.Arg(0);
    int totalRegions = 0;
    SgBWSet safe = GetSafe(totalRegions, type);
    SgPointSet set =
        (cmd.NuArg() == 2 ? safe[BlackWhiteArg(cmd, 1)] : safe.Both());
    cmd << set.Size();
    for (SgSetIterator it(set); it; ++it)
        cmd << ' ' << SgWritePoint(*it);
}
开发者ID:ernest-galbrun,项目名称:fuegoia,代码行数:17,代码来源:GoSafetyCommands.cpp

示例5: MoveArg

SgMove GoGtpCommandUtil::MoveArg(const GtpCommand& cmd, std::size_t number,
                                 const GoBoard& board)
{
    if (cmd.ArgToLower(number) == "pass")
        return SG_PASS;
    return PointArg(cmd, number, board);
}
开发者ID:Nopik,项目名称:dragongoclient,代码行数:7,代码来源:GoGtpCommandUtil.cpp

示例6: CmdQuiet

/** Switch debug logging on/off. */
void SgGtpCommands::CmdQuiet(GtpCommand& cmd)
{
    if (cmd.BoolArg(0))
        SgDebugToNull();
    else
        SgSwapDebugStr(&cerr);
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例7: CmdMoves

void GoBookCommands::CmdMoves(GtpCommand& cmd)
{
    cmd.CheckArgNone();
    vector<SgPoint> active = m_book.LookupAllMoves(m_bd);
    for (vector<SgPoint>::const_iterator it = active.begin();
         it != active.end(); ++it)
        cmd << SgWritePoint(*it) << ' ';
}
开发者ID:15418-final,项目名称:ParallelizedMCTS,代码行数:8,代码来源:GoBook.cpp

示例8: CmdCompareInt

/** Run another GTP command and compare its response against an integer value.
    Arguments: int command [arg...] <br>
    Returns: -1 if response is smaller than int; 0 if it is equal; 1 if it is
    greater
*/
void SgGtpCommands::CmdCompareInt(GtpCommand& cmd)
{
    int value = cmd.IntArg(0);
    string response = m_engine.ExecuteCommand(cmd.RemainingLine(0));
    istringstream in(response);
    int responseValue;
    in >> responseValue;
    if (! in)
        throw GtpFailure() << "response '" << response
                           << "' is not an integer";
    if (responseValue == value)
        cmd << "0";
    else if (responseValue < value)
        cmd << "-1";
    else
        cmd << "1";
}
开发者ID:,项目名称:,代码行数:22,代码来源:

示例9: Magenta

/** Information about safe points optimized for graphical display in GoGui.
    This command is compatible with GoGui's analyze command type "gfx".
    Arguments: benson|static <br>
    Returns: GoGui gfx commands to display safe points and additional
    information in the status line
    - black and white territory: safe points
    - Color Magenta (#980098): dame points
    - Color Red: safe for black and white (should not happen)
    - Circle: unsurroundable
    - Status line: point counts, percentage of safe points
*/
void GoSafetyCommands::CmdGfx(GtpCommand& cmd)
{
    cmd.CheckNuArg(1);
    string type = cmd.Arg(0);
    int totalRegions = 0;
    SgBWSet safe = GetSafe(totalRegions, type);
    SgPointSet dame;
    SgPointSet unsurroundable;
    GoSafetyUtil::FindDameAndUnsurroundablePoints(m_bd, m_bd.AllEmpty(), safe,
                                                  &dame, &unsurroundable);
    cmd << "BLACK";
    for (SgSetIterator it(safe[SG_BLACK]); it; ++it)
        cmd << ' ' << SgWritePoint(*it);
    cmd << '\n';
    cmd << "WHITE";
    for (SgSetIterator it(safe[SG_WHITE]); it; ++it)
        cmd << ' ' << SgWritePoint(*it);
    cmd << '\n';
    cmd << "COLOR #980098";
    for (SgSetIterator it(dame); it; ++it)
        cmd << ' ' << SgWritePoint(*it);
    cmd << '\n';
    cmd << "CIRCLE";
    for (SgSetIterator it(unsurroundable); it; ++it)
        cmd << ' ' << SgWritePoint(*it);
    cmd << '\n';
    SgPointSet blackAndWhite = safe[SG_WHITE] & safe[SG_BLACK];
    if (blackAndWhite.Size() > 0)
    {
        // Shouldn't happen
        cmd << "COLOR red ";
        for (SgSetIterator it(blackAndWhite); it; ++it)
            cmd << ' ' << SgWritePoint(*it);
        cmd << '\n';
    }
    int nuBlack = safe[SG_BLACK].Size();
    int nuWhite = safe[SG_WHITE].Size();
    int nuPoints = m_bd.AllPoints().Size();
    cmd << "TEXT Solver: " << cmd.Arg(0)
        << "  B: " << nuBlack << " (" << (100 * nuBlack / nuPoints) << " %)"
        << "  W: " << nuWhite << " (" << (100 * nuWhite / nuPoints) << " %)"
        << "  Both: " << (nuBlack + nuWhite)
        << " (" << (100 * (nuBlack + nuWhite) / nuPoints) << " %)"
        << "  Regions: " << totalRegions;
}
开发者ID:ernest-galbrun,项目名称:fuegoia,代码行数:56,代码来源:GoSafetyCommands.cpp

示例10:

SgVector<SgPoint> GoGtpCommandUtil::PointListArg(const GtpCommand& cmd,
                                               std::size_t number,
                                               const GoBoard& board)
{
    SgVector<SgPoint> result;
    for (size_t i = number; i < cmd.NuArg(); ++i)
        result.PushBack(PointArg(cmd, i, board));
    return result;
}
开发者ID:Nopik,项目名称:dragongoclient,代码行数:9,代码来源:GoGtpCommandUtil.cpp

示例11: CmdPid

/** Return the process ID. */
void SgGtpCommands::CmdPid(GtpCommand& cmd)
{
#if WIN32
    throw GtpFailure("command not implemented on Windows");
#else
    cmd.CheckArgNone();
    cmd << getpid();
#endif
}
开发者ID:cbordeman,项目名称:gameofgo,代码行数:10,代码来源:SgGtpCommands.cpp

示例12: CmdDebugger

/** Run a debugger and attach it to the current program.
    Arguments: debugger-type <br>
    Currently implemented debugger types:
    - gdb_kde GDB in KDE terminal
    - gdb_gnome GDB in GNOME terminal
*/
void SgGtpCommands::CmdDebugger(GtpCommand& cmd)
{
    cmd.CheckNuArg(1);
    string type = cmd.Arg(0);
    const char* path = m_programPath;
    if (path == 0)
        throw GtpFailure("location of executable unknown");
    pid_t pid = getpid();
    ostringstream s;
    if (type == "gdb_kde")
        s << "konsole -e gdb " << path << ' ' << pid << " &";
    else if (type == "gdb_gnome")
        s << "gnome-terminal -e 'gdb " << path << ' ' << pid << "' &";
    else
        throw GtpFailure() << "unknown debugger: " << type;
    SgDebug() << "Executing: " << s.str() << '\n';
    int retval = system(s.str().c_str());
    if (retval != 0)
        throw GtpFailure() << "command returned " << retval;
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例13: BlackWhiteArg

SgBlackWhite GoGtpCommandUtil::BlackWhiteArg(const GtpCommand& cmd,
                                             std::size_t number)
{
    string value = cmd.ArgToLower(number);
    if (value == "b" || value == "black")
        return SG_BLACK;
    if (value == "w" || value == "white")
        return SG_WHITE;
    throw GtpFailure() << "argument " << (number + 1)
                       << " must be black or white";
}
开发者ID:Nopik,项目名称:dragongoclient,代码行数:11,代码来源:GoGtpCommandUtil.cpp

示例14: CmdDameStatic

/** Return dame points after running static safety algorithm. */
void GoSafetyCommands::CmdDameStatic(GtpCommand& cmd)
{
    cmd.CheckArgNone();
    GoModBoard modBoard(m_bd);
    GoBoard& bd = modBoard.Board();
    GoRegionBoard regionAttachment(bd);
    GoSafetySolver solver(bd, &regionAttachment);
    SgBWSet safe;
    solver.FindSafePoints(&safe);
    SgPointSet dame = GoSafetyUtil::FindDamePoints(bd, m_bd.AllEmpty(), safe);
    cmd << SgWritePointSet(dame, "", false);
}
开发者ID:ernest-galbrun,项目名称:fuegoia,代码行数:13,代码来源:GoSafetyCommands.cpp

示例15: CmdParam

/** Set global parameters used in module SmartGame.
    Parameters:
    @arg @c time_mode cpu|real See SgTime */
void SgGtpCommands::CmdParam(GtpCommand& cmd)
{
    cmd.CheckNuArgLessEqual(2);
    if (cmd.NuArg() == 0)
    {
        // Boolean parameters first for better layout of GoGui parameter
        // dialog, alphabetically otherwise
        cmd << "[list/cpu/real] time_mode "
            << TimeModeToString(SgTime::DefaultMode()) << '\n';
    }
    else if (cmd.NuArg() >= 1 && cmd.NuArg() <= 2)
    {
        string name = cmd.Arg(0);
        if (name == "time_mode")
            SgTime::SetDefaultMode(TimeModeArg(cmd, 1));
        else
            throw GtpFailure() << "unknown parameter: " << name;
    }
    else
        throw GtpFailure() << "need 0 or 2 arguments";
}
开发者ID:cbordeman,项目名称:gameofgo,代码行数:24,代码来源:SgGtpCommands.cpp


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