SC2API
An API for AI for StarCraft II
sc2_control_interfaces.h
1 #pragma once
2 
3 #include "sc2api/sc2_data.h"
4 #include "sc2api/sc2_proto_interface.h"
5 #include "sc2api/sc2_client.h"
6 #include "sc2api/sc2_game_settings.h"
7 
8 #include <vector>
9 #include <string>
10 
11 namespace sc2 {
12 
13 struct ProcessInfo;
14 struct InterfaceSettings;
15 
17 public:
18  virtual ~ControlInterface() = default;
19 
20  virtual ProtoInterface& Proto() = 0;
21  virtual bool Connect(const std::string& address, int port, int timeout_ms) = 0;
22  virtual bool RemoteSaveMap(const void* data, int data_size, std::string remote_path) = 0;
23  virtual bool CreateGame(const std::string& map_path, const std::vector<PlayerSetup>& players, bool realtime) = 0;
24 
25  virtual bool RequestJoinGame(PlayerSetup setup, const InterfaceSettings& settings, const Ports& ports = Ports()) = 0;
26  virtual bool WaitJoinGame() = 0;
27 
28  virtual bool RequestLeaveGame() = 0;
29  virtual bool PollLeaveGame() = 0;
30 
31  virtual bool Step(int count = 1) = 0;
32  virtual bool WaitStep() = 0;
33 
34  virtual bool SaveReplay(const std::string& path) = 0;
35 
36  virtual bool Ping() = 0;
37 
38  // General.
39  virtual GameResponsePtr WaitForResponse() = 0;
40  virtual void SetProcessInfo(const ProcessInfo& pi) = 0;
41  virtual const ProcessInfo& GetProcessInfo() const = 0;
42 
43  virtual AppState GetAppState() const = 0;
44 
45  virtual SC2APIProtocol::Status GetLastStatus() const = 0;
46  virtual bool IsInGame() const = 0;
47  virtual bool IsFinishedGame() const = 0;
48  virtual bool IsReadyForCreateGame() const = 0;
49  virtual bool HasResponsePending() const = 0;
50 
51  virtual bool GetObservation() = 0;
52  virtual bool PollResponse() = 0;
53  virtual bool ConsumeResponse() = 0;
54 
55  virtual bool IssueEvents(const std::vector<Tag>& commands = {}) = 0;
56  virtual void OnGameStart() = 0;
57 
58  // Diagnostic.
59  virtual void DumpProtoUsage() = 0;
60 
61  virtual void Error(ClientError error, const std::vector<std::string>& errors={}) = 0;
62  virtual void ErrorIf(bool condition, ClientError error, const std::vector<std::string>& errors={}) = 0;
63 
64  virtual const std::vector<ClientError>& GetClientErrors() const = 0;
65  virtual const std::vector<std::string>& GetProtocolErrors() const = 0;
66 
67  virtual void ClearClientErrors() = 0;
68  virtual void ClearProtocolErrors() = 0;
69 
70  virtual void UseGeneralizedAbility(bool value) = 0;
71 
72  // Save/Load.
73  virtual void Save() = 0;
74  virtual void Load() = 0;
75 };
76 
78 public:
79  virtual ~AgentControlInterface() = default;
80 
81  virtual bool Restart() = 0;
82 };
83 
85 public:
86  virtual ~ReplayControlInterface() = default;
87 
88  virtual bool GatherReplayInfo(const std::string& path, bool download_data = false) = 0;
89  virtual bool LoadReplay(const std::string& replay_path, const InterfaceSettings& settings, uint32_t player_id, bool realtime=false) = 0;
90  virtual bool WaitForReplay() = 0;
91  virtual void UseGeneralizedAbility(bool value) = 0;
92 
93  virtual const ReplayInfo& GetReplayInfo() const = 0;
94 };
95 
96 }
Information about a running process.
Definition: sc2_game_settings.h:11
Information about a replay file.
Definition: sc2_gametypes.h:163
Definition: sc2_action.h:9
ClientError
Definition: sc2_client.h:28
Settings for rendered feature layer output.
Definition: sc2_game_settings.h:83
Port setup for one or more clients in a game.
Definition: sc2_gametypes.h:110
Definition: sc2_control_interfaces.h:84
The base class for Agent and ReplayObserver.
Definition: sc2_control_interfaces.h:16
Definition: sc2_proto_interface.h:85
Setup for a player in a game.
Definition: sc2_gametypes.h:57
Definition: sc2_control_interfaces.h:77