Exemplo n.º 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;
}
Exemplo n.º 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;
}
Exemplo n.º 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);
}
Exemplo n.º 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());
    }
}
Exemplo n.º 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 ("");
}
Exemplo n.º 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 = "";
}
Exemplo n.º 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);
}
Exemplo n.º 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();
}
Exemplo n.º 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
}
Exemplo n.º 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();
}
Exemplo n.º 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());
    }
}
Exemplo n.º 12
0
// A simple command.
void CAdd (Gtp::Io& io) {
  io.out << io.Read<int>() + io.Read<int>(11);
  io.CheckEmpty ();
}
Exemplo n.º 13
0
void Protocol::CSetMaxTreeDepth(Gtp::Io& inout) {
    int depth = inout.Read<int>();
    inout.CheckEmpty();
    game.SetMaxUTCTreeDepth(depth);
}
Exemplo n.º 14
0
void Protocol::CClearBoard(Gtp::Io& inout) {
    inout.CheckEmpty();
    game.ClearBoard();
}
Exemplo n.º 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);
}
Exemplo n.º 16
0
void Admin::CAddEngineConfigLine (Gtp::Io& io) {
  config += "\n" + QString::fromStdString (io.ReadLine ());
  io.CheckEmpty ();
}
Exemplo n.º 17
0
void Admin::CCloseAllExperiments (Gtp::Io& io) {
  io.CheckEmpty();
  db.CloseAllExperiments();
}
Exemplo n.º 18
0
void Protocol::CSetPlayoutsPerMove(Gtp::Io& inout) {
	uint playouts = inout.Read<uint>();
	inout.CheckEmpty();
	game.SetPlayoutsPerMove(playouts);
}