6 #include "sc2_proto_interface.h" 11 #include <unordered_map> 17 class ObservationInterface;
32 target_unit_tag(NullTag),
198 typedef std::vector<const Unit*> Units;
199 typedef std::unordered_map<Tag, size_t> UnitIdxMap;
203 Unit* CreateUnit(Tag tag);
204 Unit* GetUnit(Tag tag)
const;
205 Unit* GetExistingUnit(Tag tag)
const;
206 void MarkDead(Tag tag);
209 void ForEachExistingUnit(
const std::function<
void(
Unit& unit)>& functor)
const;
210 void ClearExisting();
211 bool UnitExists(Tag tag);
214 void IncrementIndex();
216 static const size_t ENTRY_SIZE = 1000;
217 typedef std::pair<size_t, size_t> PoolIndex;
219 std::vector<std::vector<Unit> > unit_pool_;
220 PoolIndex available_index_;
221 std::unordered_map<Tag, Unit*> tag_to_unit_;
222 std::unordered_map<Tag, Unit*> tag_to_existing_unit_;
227 IsUnit(UNIT_TYPEID type) : type_(type) {};
229 bool operator()(
const Unit& unit) {
return unit.
unit_type == type_; };
234 IsUnits(std::vector<UNIT_TYPEID> types) : types_(types) {};
235 std::vector<UNIT_TYPEID> types_;
236 bool operator()(
const Unit& unit) {
237 bool included =
false;
238 for (
const auto& type : types_) {
239 included = included || (unit.
unit_type == type);
uint32_t last_seen_game_loop
The last time the unit was seen.
Definition: sc2_unit.h:193
bool is_on_screen
Visible and within the camera frustum.
Definition: sc2_unit.h:138
float energy_max
Max energy of the unit. Not set for snapshots.
Definition: sc2_unit.h:155
Tag tag
The tag of the unit in the transport.
Definition: sc2_unit.h:40
float health
The health of the unit in the transport.
Definition: sc2_unit.h:42
CloakState
Unit cloak state.
Definition: sc2_unit.h:95
Common data types, including points, rectangles and colors.
A unit. Could be a structure, a worker or a military unit.
Definition: sc2_unit.h:69
Alliance
Relationship to this player.
Definition: sc2_unit.h:83
std::vector< UnitOrder > orders
Orders on a unit. Only valid for this player's units.
Definition: sc2_unit.h:170
Definition: sc2_common.h:14
int owner
Which player owns a unit.
Definition: sc2_unit.h:116
bool is_blip
Detected by sensor tower.
Definition: sc2_unit.h:140
Definition: sc2_common.h:49
float radius
Radius of the unit.
Definition: sc2_unit.h:123
Determines if the unit matches the unit type.
Definition: sc2_unit.h:226
bool is_alive
Whether the unit is alive or not.
Definition: sc2_unit.h:191
Definition: sc2_action.h:9
float energy_max
The max possible energy of the unit in the transport.
Definition: sc2_unit.h:52
UnitTypeID unit_type
An identifier of the type of unit.
Definition: sc2_unit.h:114
std::vector< PassengerUnit > passengers
Passengers in this transport. Only valid for this player's units.
Definition: sc2_unit.h:174
CloakState cloak
If the unit is cloaked.
Definition: sc2_unit.h:128
A list of enums provided for your convenience.
float shield
The shield of the unit in the transport.
Definition: sc2_unit.h:46
float shield_max
The max possible shield of the unit in the transport.
Definition: sc2_unit.h:48
float health
Health of the unit. Not set for snapshots.
Definition: sc2_unit.h:145
float radar_range
Range of radar for units that are radar units.
Definition: sc2_unit.h:133
UnitTypeID unit_type
The type of unit in the transport.
Definition: sc2_unit.h:54
float facing
Direction the unit faces in radians (1 radian == 57.296 degrees)
Definition: sc2_unit.h:121
A passenger on a transport.
Definition: sc2_unit.h:38
float progress
Progress of the order.
Definition: sc2_unit.h:28
int ideal_harvesters
Number of harvesters that can be assigned to a town hall (e.g., Command Center). Only valid for this ...
Definition: sc2_unit.h:182
int cargo_space_taken
Number of cargo slots used in the transport. Only valid for this player's units.
Definition: sc2_unit.h:176
Tag target_unit_tag
Target unit of the order, if there is one.
Definition: sc2_unit.h:24
Determines if units matches the unit type.
Definition: sc2_unit.h:233
float energy
The energy of the unit in the transport.
Definition: sc2_unit.h:50
Definition: sc2_unit.h:201
float shield_max
Max shield of the unit. Not set for snapshots.
Definition: sc2_unit.h:151
Point3D pos
Position of the unit in the world.
Definition: sc2_unit.h:119
float build_progress
Gives progress under construction. Range: [0.0, 1.0]. 1.0 == finished.
Definition: sc2_unit.h:125
Tag add_on_tag
Add-on like a tech lab or reactor. Only valid for this player's units.
Definition: sc2_unit.h:172
float weapon_cooldown
Time remaining for a weapon on cooldown. Not set for snapshots.
Definition: sc2_unit.h:165
Types used in setting up a game.
float energy
Energy of the unit. Not set for snapshots.
Definition: sc2_unit.h:153
AbilityID ability_id
Ability ID that triggered the order.
Definition: sc2_unit.h:22
Point2D target_pos
Target position of the order, if there is one.
Definition: sc2_unit.h:26
An order that is active on a unit.
Definition: sc2_unit.h:20
Alliance alliance
Relationship of the unit to this player.
Definition: sc2_unit.h:109
int mineral_contents
Amount of minerals if the unit is a mineral field. Not set for snapshots.
Definition: sc2_unit.h:157
std::vector< BuffID > buffs
Buffs on this unit. Only valid for this player's units.
Definition: sc2_unit.h:186
float shield
Shield of the unit. Not set for snapshots.
Definition: sc2_unit.h:149
int vespene_contents
Amount of vespene if the unit is a geyser. Not set for snapshots.
Definition: sc2_unit.h:159
float health_max
The max possible health of the unit in the transport.
Definition: sc2_unit.h:44
float health_max
Max health for the unit. Not set for snapshots.
Definition: sc2_unit.h:147
bool is_burrowed
If the unit is burrowed. Not set for snapshots.
Definition: sc2_unit.h:163
Tag engaged_target_tag
Target unit of a unit. Only valid for this player's units.
Definition: sc2_unit.h:184
bool is_flying
If the unit is flying. Not set for snapshots.
Definition: sc2_unit.h:161
int assigned_harvesters
Number of harvesters associated with a town hall (e.g., Command Center). Only valid for this player's...
Definition: sc2_unit.h:180
float detect_range
Range of detector for detector units.
Definition: sc2_unit.h:131
bool is_powered
Whether the unit is powered by a pylon.
Definition: sc2_unit.h:188
int cargo_space_max
Number of cargo slots available for a transport. Only valid for this player's units.
Definition: sc2_unit.h:178
Tag tag
A unique identifier for the instance of a unit.
Definition: sc2_unit.h:112
bool is_selected
If the unit is in the current selection of the player.
Definition: sc2_unit.h:136
DisplayType display_type
If the unit is shown on screen or not.
Definition: sc2_unit.h:107
DisplayType
If the unit is shown on screen or not.
Definition: sc2_unit.h:72