SC2API
An API for AI for StarCraft II
sc2_coordinator.h
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include <vector>
12 #include <string>
13 #include "sc2api/sc2_game_settings.h"
14 #include "sc2api/sc2_proto_interface.h"
15 
16 namespace sc2 {
17 
18 class Agent;
19 class ReplayObserver;
20 class CoordinatorImp;
21 
23 class Coordinator {
24 public:
25  Coordinator();
26  ~Coordinator();
27 
28  // Initialization and setup.
29 
37  bool LoadSettings(int argc, char** argv);
38 
42  void SetMultithreaded(bool value);
43 
47  void SetRealtime(bool value);
48 
51  void SetStepSize(int step_size);
52 
55  void SetProcessPath(const std::string& path);
56 
60  void SetDataVersion(const std::string& version);
61 
64  void SetTimeoutMS(uint32_t timeout_ms = kDefaultProtoInterfaceTimeout);
65 
68  void SetPortStart(int port_start);
69 
73  void SetFeatureLayers(const FeatureLayerSettings& settings);
74 
77  void SetRender(const RenderSettings& settings);
78 
82  void SetWindowSize(int width, int height);
83 
87  void SetWindowLocation(int x, int y);
88 
91  void SetUseGeneralizedAbilityId(bool value);
92 
94  // \param option The string to be appended to the executable invoke.
95  void AddCommandLine(const std::string& option);
96 
98  // \param participants A vector of player setups for each participant in the game.
99  // \sa PlayerSetup
100  void SetParticipants(const std::vector<PlayerSetup>& participants);
101 
102  void SetReplayRecovery(bool value);
103 
105  // \param replay_observer A pointer to the replay observer to utilize.
106  // \sa ReplayObserver
107  void AddReplayObserver(ReplayObserver* replay_observer);
108 
109  // Start-up.
110 
112  void LaunchStarcraft();
113 
115  void Connect(int port);
116 
123  bool StartGame(const std::string& map_path = std::string());
124 
128  bool CreateGame(const std::string& map_path = std::string());
129 
132  bool JoinGame();
133 
138  void SetupPorts(size_t num_agents, int port_start, bool check_single = true);
139 
140  // Run.
141 
154  bool Update();
155 
157  void LeaveGame();
158 
159  // Status.
160 
162  bool AllGamesEnded() const;
163 
164  // Replay specific.
166  // \param path The folder path.
167  bool SetReplayPath(const std::string& path);
169  // \param path The file path.
170  bool LoadReplayList(const std::string& file_path);
172  // \param path The file path.
173  void SaveReplayList(const std::string& file_path);
176  bool HasReplays() const;
177 
178  // Misc.
179 
181  void WaitForAllResponses();
183  // \param data The map data.
184  // \param data_size The size of map data.
185  // \param remote_path The file path to save the data to.
187  bool RemoteSaveMap(const void* data, int data_size, std::string remote_path);
190  std::string GetExePath() const;
191 
192 private:
193  CoordinatorImp* imp_;
194 };
195 
196 }
bool SetReplayPath(const std::string &path)
Sets the path for to a folder of replays to analyze.
void SaveReplayList(const std::string &file_path)
Saves replays to a file.
void SetPortStart(int port_start)
Settings for an RGB rendered output.
Definition: sc2_game_settings.h:49
void SetParticipants(const std::vector< PlayerSetup > &participants)
Sets up the bots and whether they are controlled by in-built AI, human or a custom bot...
void WaitForAllResponses()
Blocks for all bots to receive any pending responses.
void AddReplayObserver(ReplayObserver *replay_observer)
Add an instance of ReplayObserver, each ReplayObserver will run a separate StarCraft II client...
void LaunchStarcraft()
Uses settings gathered from LoadSettings, specifically the path to the executable, to run StarCraft II.
Definition: sc2_action.h:9
void SetMultithreaded(bool value)
void SetProcessPath(const std::string &path)
void SetWindowLocation(int x, int y)
Coordinator of one or more clients. Used to start, step and stop games and replays.
Definition: sc2_coordinator.h:23
bool LoadSettings(int argc, char **argv)
void SetupPorts(size_t num_agents, int port_start, bool check_single=true)
void SetRealtime(bool value)
bool RemoteSaveMap(const void *data, int data_size, std::string remote_path)
Saves a binary blob as a map to a remote location.
A client for running a replay.
Definition: sc2_replay_observer.h:20
bool AllGamesEnded() const
Returns true if all running games have ended.
bool CreateGame(const std::string &map_path=std::string())
void AddCommandLine(const std::string &option)
Appends a command line argument to be fed to StarCraft II when starting.
void SetTimeoutMS(uint32_t timeout_ms=kDefaultProtoInterfaceTimeout)
bool HasReplays() const
void Connect(int port)
Attaches to a running Starcraft.
void SetUseGeneralizedAbilityId(bool value)
bool LoadReplayList(const std::string &file_path)
Loads replays from a file.
void SetWindowSize(int width, int height)
void SetFeatureLayers(const FeatureLayerSettings &settings)
void SetRender(const RenderSettings &settings)
Settings for feature layer output.
Definition: sc2_game_settings.h:65
void SetDataVersion(const std::string &version)
void SetStepSize(int step_size)
void LeaveGame()
Requests for the currently running game to end.
bool StartGame(const std::string &map_path=std::string())
std::string GetExePath() const