/** Player selection. This command is compatible with the GoGui analyze command type "param". Parameters: @arg @c player Player id as in FuegoTestEngine::SetPlayer */ void FuegoTestEngine::CmdParam(GtpCommand& cmd) { cmd.CheckNuArgLessEqual(2); if (cmd.NuArg() == 0) { cmd << "[list/<none>/average/capture/dumbtactic/greedy/influence/" "ladder/liberty/maxeye/minlib/no-search/random/safe] player " << (m_playerId == "" ? "<none>" : m_playerId) << '\n'; } else if (cmd.NuArg() >= 1 && cmd.NuArg() <= 2) { string name = cmd.Arg(0); if (name == "player") { try { string id = trim_copy(cmd.RemainingLine(0)); if (id == "<none>") id = ""; SetPlayer(id); } catch (const SgException& e) { throw GtpFailure(e.what()); } } else throw GtpFailure() << "unknown parameter: " << name; } else throw GtpFailure() << "need 0 or 2 arguments"; }
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; }
/** 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"; }
/** 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); }
void GoGtpCommandUtil::ParseMultiStoneArgument(GtpCommand& cmd, const GoBoard& board, SgBlackWhite& toPlay, SgBlackWhite& defender, SgVector<SgPoint>& crucial) { toPlay = GoGtpCommandUtil::BlackWhiteArg(cmd, 0); SgDebug() << "Set " << SgBW(toPlay) << " to play\n"; SgPoint point = GoGtpCommandUtil::StoneArg(cmd, 1, board); defender = board.GetColor(point); SG_ASSERT(defender == SG_BLACK || defender == SG_WHITE); crucial.PushBack(point); for (size_t i = 2; i < cmd.NuArg(); ++i) { SgPoint p = GoGtpCommandUtil::StoneArg(cmd, i, board); if (board.GetColor(p) != defender) throw GtpFailure("Crucial stones must be same color"); else crucial.PushBack(p); } }