void Protocol::CShowTree(Gtp::Io& inout) { uint children = inout.Read<uint>(4); inout.CheckEmpty(); std::string ascii_tree; game.PrintTree(ascii_tree, children); inout.out << std::endl << ascii_tree; }
void Protocol::CShowBoard(Gtp::Io& inout) { inout.CheckEmpty(); inout.out << std::endl; std::string ascii_board; game.PrintBoard(ascii_board); inout.out << ascii_board; }
void Admin::CAddExperimentParam (Gtp::Io& io) { Param p; p.name = QString::fromStdString (io.Read<std::string>()); p.min_value = io.Read<double>(); p.max_value = io.Read<double>(); p.SetFun (QString::fromStdString (io.Read<std::string>())); io.CheckEmpty(); experiment_params.append (p); }
void Protocol::CBoardSize(Gtp::Io& inout) { uint boardSize = inout.Read<uint>(); inout.CheckEmpty(); if (boardSize != Dim::board_size) { std::stringstream err; err << "the only supported board size is " << Dim::board_size; inout.SetError(err.str()); } }
void Admin::CAddGameSetup (Gtp::Io& io) { QString name = QString::fromStdString (io.Read<std::string>()); int board_size = io.Read<int>(); float komi = io.Read<float>(); io.CheckEmpty(); if (!db.AddGameSetup (name, board_size, komi)) io.SetError (""); }
void Admin::CAddEngine (Gtp::Io& io) { QString name = QString::fromStdString (io.Read<std::string>()); io.CheckEmpty(); if (!AddEngine (name, config, command_line)) io.SetError (""); name = ""; config = ""; command_line = ""; }
void Protocol::CTimeManagement(Gtp::Io& inout) { if (inout.IsEmpty()) { inout.out << game.GetTimeManager().management << '\n'; inout.out << kManagementPlayoutsPerMove << ' ' << "playouts per move\n"; inout.out << kManagementPlayoutMovesPerGame << ' ' << "playout moves per game\n"; inout.out << kManagementTime << ' ' << "time"; return; } uint choice = inout.Read<uint>(); inout.CheckEmpty(); game.GetTimeManager().management = TimeManagementType(choice); }
void Protocol::CGenMoveNoPlay(Gtp::Io& inout) { std::string player = inout.Read<std::string>(); inout.CheckEmpty(); if (game.IsFinished()) { inout.SetError("game is finished"); return; } Move move = game.GenMove(Player::OfString(player)); inout.out << move.GetLocation().ToCoords(); }
void Admin::CAddExperiment (Gtp::Io& io) { QString game_setup = QString::fromStdString (io.Read<std::string>()); io.CheckEmpty(); QStringList ps; foreach (const Param& param, experiment_params) ps.append (param.name); experiment_id = db.AddExperiment (game_setup, first_engine, second_engine, experiment_description, ps); CHECK (experiment_id > 0); first_engine = ""; second_engine = ""; experiment_description = ""; // experiment_params.clear(); // TODO solve it better }
void Protocol::CGenMove(Gtp::Io& inout) { std::string player = inout.Read<std::string>(); inout.CheckEmpty(); if (!Player::ValidPlayer(player)) { inout.SetError("invalid parameters"); return; } if (game.IsFinished()) { inout.SetError("game is finished"); return; } ASSERT (Player::OfString(player) == game.CurrentPlayer()); Move move = game.GenMove(); game.Play(move); inout.out << move.GetLocation().ToCoords(); }
void Protocol::CPlay(Gtp::Io& inout) { std::string player = inout.Read<std::string>(); std::string location = inout.Read<std::string>(); inout.CheckEmpty(); if (!Player::ValidPlayer(player) || !Location::ValidLocation(location)) { inout.SetError("invalid parameters"); return; } Move move = Move(Player::OfString(player), Location::OfCoords(location)); if (game.IsValidMove(move)) { game.Play(move); } else { std::stringstream err; err << "invalid move: " << location; inout.SetError(err.str()); } }
// A simple command. void CAdd (Gtp::Io& io) { io.out << io.Read<int>() + io.Read<int>(11); io.CheckEmpty (); }
void Protocol::CSetMaxTreeDepth(Gtp::Io& inout) { int depth = inout.Read<int>(); inout.CheckEmpty(); game.SetMaxUTCTreeDepth(depth); }
void Protocol::CClearBoard(Gtp::Io& inout) { inout.CheckEmpty(); game.ClearBoard(); }
void Protocol::CAvoidingBridges(Gtp::Io& inout) { int value = inout.Read<int>(); inout.CheckEmpty(); if (value == 0) game.setAvoidingBridges(false); else game.setAvoidingBridges(true); }
void Admin::CAddEngineConfigLine (Gtp::Io& io) { config += "\n" + QString::fromStdString (io.ReadLine ()); io.CheckEmpty (); }
void Admin::CCloseAllExperiments (Gtp::Io& io) { io.CheckEmpty(); db.CloseAllExperiments(); }
void Protocol::CSetPlayoutsPerMove(Gtp::Io& inout) { uint playouts = inout.Read<uint>(); inout.CheckEmpty(); game.SetPlayoutsPerMove(playouts); }