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  void SetReplayPerspective(int player_id);
95 
97  // \param option The string to be appended to the executable invoke.
98  void AddCommandLine(const std::string& option);
99 
102  void SetRawAffectsSelection(bool value);
103 
109  void SetFullScreen(bool value);
110 
112  // \param participants A vector of player setups for each participant in the game.
113  // \sa PlayerSetup
114  void SetParticipants(const std::vector<PlayerSetup>& participants);
115 
116  void SetReplayRecovery(bool value);
117 
119  // \param replay_observer A pointer to the replay observer to utilize.
120  // \sa ReplayObserver
121  void AddReplayObserver(ReplayObserver* replay_observer);
122 
123  // Start-up.
124 
126  void LaunchStarcraft();
127 
129  void Connect(int port);
130 
137  bool StartGame(const std::string& map_path = std::string());
138 
142  bool CreateGame(const std::string& map_path = std::string());
143 
146  bool JoinGame();
147 
152  void SetupPorts(size_t num_agents, int port_start, bool check_single = true);
153 
154  // Run.
155 
168  bool Update();
169 
171  void LeaveGame();
172 
173  // Status.
174 
176  bool AllGamesEnded() const;
177 
178  // Replay specific.
180  // \param path The folder path.
181  bool SetReplayPath(const std::string& path);
183  // \param path The file path.
184  bool LoadReplayList(const std::string& file_path);
186  // \param path The file path.
187  void SaveReplayList(const std::string& file_path);
190  bool HasReplays() const;
191 
192  // Misc.
193 
195  void WaitForAllResponses();
197  // \param data The map data.
198  // \param data_size The size of map data.
199  // \param remote_path The file path to save the data to.
201  bool RemoteSaveMap(const void* data, int data_size, std::string remote_path);
204  std::string GetExePath() const;
205 
206 private:
207  CoordinatorImp* imp_;
208 };
209 
210 }
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:51
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 SetReplayPerspective(int player_id)
Sets the replay perspective. Use 0 to observe all players.
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.
void SetRawAffectsSelection(bool value)
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 CreateGame(const std::string &map_path=std::string())
bool AllGamesEnded() const
Returns true if all running games have ended.
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)
void Connect(int port)
Attaches to a running Starcraft.
void SetUseGeneralizedAbilityId(bool value)
bool HasReplays() const
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)
std::string GetExePath() const
Settings for feature layer output.
Definition: sc2_game_settings.h:67
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())
void SetFullScreen(bool value)