Exemple #1
0
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;
}
Exemple #2
0
void Protocol::CShowBoard(Gtp::Io& inout) {
    inout.CheckEmpty();
    inout.out << std::endl;
    std::string ascii_board;
    game.PrintBoard(ascii_board);
    inout.out << ascii_board;
}
Exemple #3
0
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);
}
Exemple #4
0
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());
    }
}
Exemple #5
0
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 ("");
}
Exemple #6
0
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 = "";
}
Exemple #7
0
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);
}
Exemple #8
0
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();
}
Exemple #9
0
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
}
Exemple #10
0
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();
}
Exemple #11
0
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());
    }
}
Exemple #12
0
// A simple command.
void CAdd (Gtp::Io& io) {
  io.out << io.Read<int>() + io.Read<int>(11);
  io.CheckEmpty ();
}
Exemple #13
0
void Protocol::CSetMaxTreeDepth(Gtp::Io& inout) {
    int depth = inout.Read<int>();
    inout.CheckEmpty();
    game.SetMaxUTCTreeDepth(depth);
}
Exemple #14
0
void Protocol::CClearBoard(Gtp::Io& inout) {
    inout.CheckEmpty();
    game.ClearBoard();
}
Exemple #15
0
void Protocol::CAvoidingBridges(Gtp::Io& inout) {
    int value = inout.Read<int>();
    inout.CheckEmpty();
    if (value == 0) game.setAvoidingBridges(false);
    else game.setAvoidingBridges(true);
}
Exemple #16
0
void Admin::CAddEngineConfigLine (Gtp::Io& io) {
  config += "\n" + QString::fromStdString (io.ReadLine ());
  io.CheckEmpty ();
}
Exemple #17
0
void Admin::CCloseAllExperiments (Gtp::Io& io) {
  io.CheckEmpty();
  db.CloseAllExperiments();
}
Exemple #18
0
void Protocol::CSetPlayoutsPerMove(Gtp::Io& inout) {
	uint playouts = inout.Read<uint>();
	inout.CheckEmpty();
	game.SetPlayoutsPerMove(playouts);
}