SC2API
An API for AI for StarCraft II
sc2_map_info.h
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "sc2_common.h"
7 #include "sc2_gametypes.h"
8 
9 #include "s2clientprotocol/sc2api.pb.h"
10 
11 #include <string>
12 #include <vector>
13 
14 namespace sc2 {
15 
17 struct ImageData {
18  int width;
19  int height;
20  int bits_per_pixel;
21  std::string data;
22 
23  ImageData();
24 };
25 
27 struct RenderedFrame {
28  ImageData map;
29  ImageData minimap;
30 };
31 
33 struct SpatialSetup {
35  float camera_width;
44 };
45 
49  bool raw;
54 };
55 
56 struct PlayerInfo {
57  uint32_t player_id;
58  PlayerType player_type;
59  Race race_requested;
60  Race race_actual;
61  Difficulty difficulty;
62  AIBuild ai_build;
63  std::string player_name;
64 
65  PlayerInfo(uint32_t player_id, PlayerType player_type,
66  Race race_requested, Race race_actual,
67  Difficulty difficulty, AIBuild ai_build,
68  const std::string& player_name):
69  player_id(player_id),
70  player_type(player_type),
71  race_requested(race_requested),
72  race_actual(race_actual),
73  difficulty(difficulty),
74  ai_build(ai_build),
75  player_name(player_name) {};
76 };
77 
79 struct GameInfo {
81  std::string map_name;
83  std::string local_map_path;
85  int width;
87  int height;
99  std::vector<Point2D> enemy_start_locations;
100  std::vector<Point2D> start_locations;
101 
105 
106  std::vector<PlayerInfo> player_info;
107 
108  GameInfo();
109 };
110 
111 struct SampleImage {
112  explicit SampleImage(const SC2APIProtocol::ImageData& data);
113 
114  explicit SampleImage(const ImageData& data);
115 
116  bool GetBit(const Point2DI& point, bool* dst) const;
117 
118  bool GetBit(const Point2DI& point, unsigned char* dst) const;
119 
120  int BPP() const;
121 
122  Rect2DI Area() const;
123 
124 private:
125  const std::string& data_;
126  Rect2DI area_;
127 
128  // NOTE (alkurbatov): Possible bits per pixel values specified in
129  // protocol/s2clientprotocol/raw.proto
130  int bits_per_pixel_;
131 };
132 
133 struct PathingGrid {
134  explicit PathingGrid(const GameInfo& info);
135 
136  bool IsPathable(const Point2DI& point) const;
137 
138  void Dump(const std::string& file_path) const;
139 
140 private:
141  SampleImage pathing_grid_;
142 };
143 
145  explicit PlacementGrid(const GameInfo& info);
146 
147  bool IsPlacable(const Point2DI& point) const;
148 
149  void Dump(const std::string& file_path) const;
150 
151 private:
152  SampleImage placement_grid_;
153 };
154 
155 struct HeightMap {
156  explicit HeightMap(const GameInfo& info);
157 
158  float TerrainHeight(const Point2DI& point) const;
159 
160  void Dump(const std::string& file_path) const;
161 
162 private:
163  SampleImage height_map_;
164 };
165 
166 }
int width
World width of a map.
Definition: sc2_map_info.h:85
int minimap_resolution_x
Number of pixels in X of the minimap.
Definition: sc2_map_info.h:41
Definition: sc2_map_info.h:111
std::string map_name
Plain text name of a map. Note that this may be different from the filename of the map...
Definition: sc2_map_info.h:81
std::string local_map_path
Filename of map. Includes the ".SC2Map" file extension.
Definition: sc2_map_info.h:83
Common data types, including points, rectangles and colors.
2D integer point.
Definition: sc2_common.h:94
float camera_width
For feature layers only, determines the world space size of the camera.
Definition: sc2_map_info.h:35
Definition: sc2_common.h:49
Setup structure for feature layers or rendered images.
Definition: sc2_map_info.h:33
Definition: sc2_map_info.h:56
ImageData pathing_grid
Grid showing which cells are pathable by units.
Definition: sc2_map_info.h:89
SpatialSetup feature_layer
Feature layer data.
Definition: sc2_map_info.h:51
Definition: sc2_action.h:9
Point2D playable_max
The maximum coordinates of playable space. Points greater than this are not playable.
Definition: sc2_map_info.h:97
Definition: sc2_map_info.h:155
std::vector< Point2D > enemy_start_locations
Positions of possible enemy starting locations.
Definition: sc2_map_info.h:99
int height
World height of a map.
Definition: sc2_map_info.h:87
int map_resolution_y
Number of pixels in Y of the main game view.
Definition: sc2_map_info.h:39
Rendered data for a game frame.
Definition: sc2_map_info.h:27
InterfaceOptions options
Definition: sc2_map_info.h:104
ImageData placement_grid
Grid showing which cells can accept placement of structures.
Definition: sc2_map_info.h:93
Definition: sc2_map_info.h:133
Determines what type of data will be returned in observations.
Definition: sc2_map_info.h:47
int map_resolution_x
Number of pixels in X of the main game view.
Definition: sc2_map_info.h:37
Definition: sc2_map_info.h:144
bool raw
Raw data; essentially a list of units.
Definition: sc2_map_info.h:49
Point2D playable_min
The minimum coordinates of playable space. Points less than this are not playable.
Definition: sc2_map_info.h:95
Types used in setting up a game.
2D integer rectangle.
Definition: sc2_common.h:113
Initial data for a game and map.
Definition: sc2_map_info.h:79
int minimap_resolution_y
Number of pixels in Y of the minimap.
Definition: sc2_map_info.h:43
ImageData terrain_height
Height map of terrain.
Definition: sc2_map_info.h:91
SpatialSetup render
Rendered image data.
Definition: sc2_map_info.h:53
Data for a feature layer or rendered image.
Definition: sc2_map_info.h:17