TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
torchcraftclient.h
1 /*
2  * Copyright (c) 2017-present, Facebook, Inc.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #pragma once
9 
10 #include <torchcraft/client.h>
11 
12 #include <memory>
13 #include <string>
14 #include <vector>
15 
16 namespace cherrypi {
17 
18 template <typename procT>
19 std::shared_ptr<torchcraft::Client> makeTorchCraftClient(
20  procT&& proc,
22  int timeout) {
23  auto client = std::make_shared<torchcraft::Client>();
24  if (!proc->connect(client.get(), timeout)) {
25  throw std::runtime_error(
26  std::string("Error establishing connection: ") + client->error());
27  }
28 
29  // Perform handshake
30  std::vector<std::string> upd;
31  if (!client->init(upd, opts)) {
32  throw std::runtime_error(
33  std::string("Error initializing connection: ") + client->error());
34  }
35 
36  return client;
37 }
38 
39 } // namespace cherrypi
std::shared_ptr< torchcraft::Client > makeTorchCraftClient(procT &&proc, torchcraft::Client::Options opts, int timeout)
Definition: torchcraftclient.h:19
Definition: client.h:27
Main namespace for bot-related code.
Definition: areainfo.cpp:17