示例#1
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());
    }
}
示例#2
0
文件: admin.cpp 项目: brownman/libego
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 ("");
}
示例#3
0
文件: admin.cpp 项目: brownman/libego
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 = "";
}
示例#4
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();
}
示例#5
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);
}
示例#6
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;
}
示例#7
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;
}
示例#8
0
文件: admin.cpp 项目: brownman/libego
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);
}
示例#9
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();
}
示例#10
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());
    }
}
示例#11
0
文件: admin.cpp 项目: brownman/libego
void Admin::CSetExperimentEngine (Gtp::Io& io)
{
  int num = io.Read<int> ();
  if (num != 1 && num != 2) {
    io.SetError ("wronge engine number");
    return;
  }
  QString name = QString::fromStdString (io.Read<std::string>());
  (num == 1 ? first_engine : second_engine) = name;
}
示例#12
0
文件: admin.cpp 项目: brownman/libego
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
}
示例#13
0
文件: gtp_test.cpp 项目: ujh/HouseBot
// A simple command.
void CAdd (Gtp::Io& io) {
  io.out << io.Read<int>() + io.Read<int>(11);
  io.CheckEmpty ();
}
示例#14
0
void Protocol::CSetMaxTreeDepth(Gtp::Io& inout) {
    int depth = inout.Read<int>();
    inout.CheckEmpty();
    game.SetMaxUTCTreeDepth(depth);
}
示例#15
0
void Protocol::CClearBoard(Gtp::Io& inout) {
    inout.CheckEmpty();
    game.ClearBoard();
}
示例#16
0
void Protocol::CSetPlayoutsPerMove(Gtp::Io& inout) {
	uint playouts = inout.Read<uint>();
	inout.CheckEmpty();
	game.SetPlayoutsPerMove(playouts);
}
示例#17
0
文件: admin.cpp 项目: brownman/libego
void Admin::CSetExperimentDescription (Gtp::Io& io) {
  experiment_description = QString::fromStdString (io.ReadLine());
}
示例#18
0
void Protocol::CAvoidingBridges(Gtp::Io& inout) {
    int value = inout.Read<int>();
    inout.CheckEmpty();
    if (value == 0) game.setAvoidingBridges(false);
    else game.setAvoidingBridges(true);
}
示例#19
0
文件: admin.cpp 项目: brownman/libego
void Admin::CAddEngineConfigLine (Gtp::Io& io) {
  config += "\n" + QString::fromStdString (io.ReadLine ());
  io.CheckEmpty ();
}
示例#20
0
文件: admin.cpp 项目: brownman/libego
void Admin::CSetEngineCommandLine (Gtp::Io& io) {
  command_line = QString::fromStdString (io.ReadLine());
}
示例#21
0
文件: admin.cpp 项目: brownman/libego
void Admin::CCloseAllExperiments (Gtp::Io& io) {
  io.CheckEmpty();
  db.CloseAllExperiments();
}