Ejemplo n.º 1
0
/** 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";
}
Ejemplo n.º 2
0
/** 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.Arg<double>(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");
}
Ejemplo n.º 3
0
/** 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.Arg<int>(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";
}