本文整理汇总了C++中GtpCommand::CheckNuArg方法的典型用法代码示例。如果您正苦于以下问题:C++ GtpCommand::CheckNuArg方法的具体用法?C++ GtpCommand::CheckNuArg怎么用?C++ GtpCommand::CheckNuArg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GtpCommand
的用法示例。
在下文中一共展示了GtpCommand::CheckNuArg方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CmdGfx
/** 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;
}
示例2: 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;
}
示例3: PointArg
SgPoint GoGtpCommandUtil::PointArg(const GtpCommand& cmd,
const GoBoard& board)
{
cmd.CheckNuArg(1);
return PointArg(cmd, 0, board);
}
示例4: SetSeed
/** Set and store random seed.
Arguments: seed <br>
See SgRandom::SetSeed(int) for the special meaning of zero and negative
values.
*/
void SgGtpCommands::CmdSetRandomSeed(GtpCommand& cmd)
{
cmd.CheckNuArg(1);
SgRandom::SetSeed(cmd.IntArg(0));
}
示例5: CmdExec
/** Execute GTP commands from a file.
Argument: filename <br>
Aborts on the first command that fails. Responses to the commands in the
file are written to SgDebug()
@see GtpEngine::ExecuteFile
*/
void SgGtpCommands::CmdExec(GtpCommand& cmd)
{
cmd.CheckNuArg(1);
m_engine.ExecuteFile(cmd.Arg(0), SgDebug());
}