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 
59  void SetTimeoutMS(uint32_t timeout_ms = kDefaultProtoInterfaceTimeout);
60 
63  void SetPortStart(int port_start);
64 
68  void SetFeatureLayers(const FeatureLayerSettings& settings);
69 
72  void SetRender(const RenderSettings& settings);
73 
77  void SetWindowSize(int width, int height);
78 
82  void SetWindowLocation(int x, int y);
83 
85  // \param option The string to be appended to the executable invoke.
86  void AddCommandLine(const std::string& option);
87 
89  // \param participants A vector of player setups for each participant in the game.
90  // \sa PlayerSetup
91  void SetParticipants(const std::vector<PlayerSetup>& participants);
92 
93  void SetReplayRecovery(bool value);
94 
96  // \param replay_observer A pointer to the replay observer to utilize.
97  // \sa ReplayObserver
98  void AddReplayObserver(ReplayObserver* replay_observer);
99 
100  // Start-up.
101 
103  void LaunchStarcraft();
104 
111  bool StartGame(const std::string& map_path = std::string());
112 
113  // Run.
114 
127  bool Update();
128 
130  void LeaveGame();
131 
132  // Status.
133 
135  bool AllGamesEnded() const;
136 
137  // Replay specific.
139  // \param path The folder path.
140  bool SetReplayPath(const std::string& path);
142  // \param path The file path.
143  bool LoadReplayList(const std::string& file_path);
145  // \param path The file path.
146  void SaveReplayList(const std::string& file_path);
149  bool HasReplays() const;
150 
151  // Misc.
152 
154  void WaitForAllResponses();
156  // \param data The map data.
157  // \param data_size The size of map data.
158  // \param remote_path The file path to save the data to.
160  bool RemoteSaveMap(const void* data, int data_size, std::string remote_path);
163  std::string GetExePath() const;
164 
165 private:
166  CoordinatorImp* imp_;
167 };
168 
169 }
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:42
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 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:18
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)
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:58
void SetStepSize(int step_size)
void LeaveGame()
Requests for the currently running game to end.
bool StartGame(const std::string &map_path=std::string())