SC2API
An API for AI for StarCraft II
Public Member Functions | List of all members
sc2::ObservationInterface Class Referenceabstract

The ObservationInterface reflects the current state of the game. Guaranteed to be valid when OnGameStart or OnStep is called. More...

#include <sc2_interfaces.h>

Public Member Functions

virtual uint32_t GetPlayerID () const =0
 
virtual uint32_t GetGameLoop () const =0
 
virtual Units GetUnits () const =0
 
virtual Units GetUnits (Unit::Alliance alliance, Filter filter={}) const =0
 
virtual Units GetUnits (Filter filter) const =0
 
virtual const UnitGetUnit (Tag tag) const =0
 
virtual const RawActions & GetRawActions () const =0
 
virtual const SpatialActionsGetFeatureLayerActions () const =0
 
virtual const SpatialActionsGetRenderedActions () const =0
 
virtual const std::vector< ChatMessage > & GetChatMessages () const =0
 
virtual const std::vector< PowerSource > & GetPowerSources () const =0
 
virtual const std::vector< Effect > & GetEffects () const =0
 
virtual const std::vector< UpgradeID > & GetUpgrades () const =0
 
virtual const ScoreGetScore () const =0
 
virtual const Abilities & GetAbilityData (bool force_refresh=false) const =0
 
virtual const UnitTypes & GetUnitTypeData (bool force_refresh=false) const =0
 
virtual const Upgrades & GetUpgradeData (bool force_refresh=false) const =0
 
virtual const Buffs & GetBuffData (bool force_refresh=false) const =0
 
virtual const Effects & GetEffectData (bool force_refresh=false) const =0
 
virtual const GameInfoGetGameInfo () const =0
 
virtual int32_t GetMinerals () const =0
 
virtual int32_t GetVespene () const =0
 
virtual int32_t GetFoodCap () const =0
 
virtual int32_t GetFoodUsed () const =0
 
virtual int32_t GetFoodArmy () const =0
 
virtual int32_t GetFoodWorkers () const =0
 
virtual int32_t GetIdleWorkerCount () const =0
 
virtual int32_t GetArmyCount () const =0
 
virtual int32_t GetWarpGateCount () const =0
 
virtual Point2D GetCameraPos () const =0
 
virtual Point3D GetStartLocation () const =0
 
virtual const std::vector< PlayerResult > & GetResults () const =0
 
virtual bool HasCreep (const Point2D &point) const =0
 
virtual Visibility GetVisibility (const Point2D &point) const =0
 
virtual bool IsPathable (const Point2D &point) const =0
 Returns 'true' if the given point on the terrain is pathable. This does not. More...
 
virtual bool IsPlacable (const Point2D &point) const =0
 Returns 'true' if the given point on the terrain is buildable. This does not. More...
 
virtual float TerrainHeight (const Point2D &point) const =0
 
virtual const SC2APIProtocol::Observation * GetRawObservation () const =0
 A pointer to the low-level protocol data for the current observation. While it's possible to extract most in-game data from this pointer. More...
 

Detailed Description

The ObservationInterface reflects the current state of the game. Guaranteed to be valid when OnGameStart or OnStep is called.

Member Function Documentation

virtual const Abilities& sc2::ObservationInterface::GetAbilityData ( bool  force_refresh = false) const
pure virtual

Gets metadata of abilities. Array can be indexed directly by AbilityID.

Parameters
force_refreshforces a full query from the game, may otherwise cache data from a previous call.
Returns
Data about all abilities possible for the current game session.
virtual int32_t sc2::ObservationInterface::GetArmyCount ( ) const
pure virtual

The number of army units.

Returns
Count of army units.
virtual const Buffs& sc2::ObservationInterface::GetBuffData ( bool  force_refresh = false) const
pure virtual

Gets metadata of buffs. Array can be indexed directly by BuffID.

Parameters
force_refreshforces a full query from the game, may otherwise cache data from a previous call.
Returns
Data about all buffs possible for the current game session.
virtual Point2D sc2::ObservationInterface::GetCameraPos ( ) const
pure virtual

Position of the center of the camera.

Returns
Camera position.
virtual const std::vector<ChatMessage>& sc2::ObservationInterface::GetChatMessages ( ) const
pure virtual

Gets new chat messages.

Returns
List of chat messages.
virtual const Effects& sc2::ObservationInterface::GetEffectData ( bool  force_refresh = false) const
pure virtual

Gets metadata of effects. Array can be indexed directly by EffectID.

Parameters
force_refreshforces a full query from the game, may otherwise cache data from a previous call.
Returns
Data about all effects possible for the current game session.
virtual const std::vector<Effect>& sc2::ObservationInterface::GetEffects ( ) const
pure virtual

Gets all active effects in vision of the current player.

Returns
List of effects.
virtual const SpatialActions& sc2::ObservationInterface::GetFeatureLayerActions ( ) const
pure virtual

Gets a list of actions performed. For use with the feature layer options.

Returns
List of actions.
virtual int32_t sc2::ObservationInterface::GetFoodArmy ( ) const
pure virtual

The total supply consumed by army units alone.

See also
GetFoodUsed() GetFoodWorkers()
Returns
Food used by army units.
virtual int32_t sc2::ObservationInterface::GetFoodCap ( ) const
pure virtual

The total supply cap given the players max possible supply.

Returns
Food cap.
See also
GetFoodUsed() GetFoodArmy() GetFoodWorkers()
virtual int32_t sc2::ObservationInterface::GetFoodUsed ( ) const
pure virtual

The total supply used by the player as defined: GetFoodArmy() + GetFoodWorkers().

Returns
Food used.
See also
GetFoodArmy() GetFoodWorkers()
virtual int32_t sc2::ObservationInterface::GetFoodWorkers ( ) const
pure virtual

The total supply consumed by workers units alone.

See also
GetFoodArmy() GetFoodUsed()
Returns
Food used by worker units.
virtual const GameInfo& sc2::ObservationInterface::GetGameInfo ( ) const
pure virtual

Gets the GameInfo struct for the current map.

Returns
The current GameInfo struct.
virtual uint32_t sc2::ObservationInterface::GetGameLoop ( ) const
pure virtual

Get the current game loop for this observation.

Returns
The game loop.
virtual int32_t sc2::ObservationInterface::GetIdleWorkerCount ( ) const
pure virtual

The number of workers that currently have no orders.

Returns
Count of idle workers.
virtual int32_t sc2::ObservationInterface::GetMinerals ( ) const
pure virtual

The mineral count of the player.

Returns
The mineral count.
virtual uint32_t sc2::ObservationInterface::GetPlayerID ( ) const
pure virtual

Gets a unique ID that represents the player.

Returns
The player ID.
virtual const std::vector<PowerSource>& sc2::ObservationInterface::GetPowerSources ( ) const
pure virtual

Gets all power sources associated with the current player.

Returns
List of power sources.
virtual const RawActions& sc2::ObservationInterface::GetRawActions ( ) const
pure virtual

Gets a list of actions performed as abilities applied to units. For use with the raw option.

Returns
List of raw actions.
virtual const SC2APIProtocol::Observation* sc2::ObservationInterface::GetRawObservation ( ) const
pure virtual

A pointer to the low-level protocol data for the current observation. While it's possible to extract most in-game data from this pointer.

<

Returns
A const pointer to the Observation.
See also
Observation GetObservation()
virtual const SpatialActions& sc2::ObservationInterface::GetRenderedActions ( ) const
pure virtual

Gets a list of actions performed. For use with the rendered options.

Returns
List of actions.
virtual const std::vector<PlayerResult>& sc2::ObservationInterface::GetResults ( ) const
pure virtual

Gets the results of the game.

Returns
Player results if the game ended, an empty vector otherwise.
virtual const Score& sc2::ObservationInterface::GetScore ( ) const
pure virtual

Gets the detailed current set of scores.

Returns
The current score structure.
virtual Point3D sc2::ObservationInterface::GetStartLocation ( ) const
pure virtual

Gets the initial start location of the player.

Returns
Player start position.
virtual const Unit* sc2::ObservationInterface::GetUnit ( Tag  tag) const
pure virtual

Get the unit state as represented by the last call to GetObservation.

Parameters
tagUnique tag of the unit.
Returns
Pointer to the Unit object.
virtual Units sc2::ObservationInterface::GetUnits ( ) const
pure virtual

Get a list of all known units in the game.

Returns
List of all ally and visible enemy and neutral units.
virtual Units sc2::ObservationInterface::GetUnits ( Unit::Alliance  alliance,
Filter  filter = {} 
) const
pure virtual

Get all units belonging to a certain alliance and meet the conditions provided by the filter. The unit structure is const data only. Therefore editing that data will not change any in game state. See the ActionInterface for changing Unit state.

Parameters
allianceThe faction the units belong to.
filterA functor or lambda used to filter out any unneeded units in the list.
Returns
A list of units that meet the conditions provided by alliance and filter.
virtual Units sc2::ObservationInterface::GetUnits ( Filter  filter) const
pure virtual

Get all units belonging to self that meet the conditions provided by the filter. The unit structure is const data only. Therefore editing that data will not change any in game state. See the ActionInterface for changing Unit state.

Parameters
filterA functor or lambda used to filter out any unneeded units in the list.
Returns
A list of units that meet the conditions provided by the filter.
virtual const UnitTypes& sc2::ObservationInterface::GetUnitTypeData ( bool  force_refresh = false) const
pure virtual

Gets metadata of units. Array can be indexed directly by UnitID.

Parameters
force_refreshforces a full query from the game, may otherwise cache data from a previous call.
Returns
Data about all units possible for the current game session.
virtual const Upgrades& sc2::ObservationInterface::GetUpgradeData ( bool  force_refresh = false) const
pure virtual

Gets metadata of upgrades. Array can be indexed directly by UpgradeID.

Parameters
force_refreshforces a full query from the game, may otherwise cache data from a previous call.
Returns
Data about all upgrades possible for the current game session.
virtual const std::vector<UpgradeID>& sc2::ObservationInterface::GetUpgrades ( ) const
pure virtual

Gets all upgrades.

Returns
List of upgrades.
virtual int32_t sc2::ObservationInterface::GetVespene ( ) const
pure virtual

The vespene count of the player.

Returns
The vespene count.
virtual Visibility sc2::ObservationInterface::GetVisibility ( const Point2D point) const
pure virtual

Returns visibility value of the given point for the current player.

Parameters
pointPosition to sample.
Returns
Visibility.
virtual int32_t sc2::ObservationInterface::GetWarpGateCount ( ) const
pure virtual

Number of warp gates owned by the player. This value should only be nonzero for Protoss.

Returns
Count of warp gates.
virtual bool sc2::ObservationInterface::HasCreep ( const Point2D point) const
pure virtual

Returns 'true' if the given point has creep.

Parameters
pointPosition to sample.
Returns
Creep.
virtual bool sc2::ObservationInterface::IsPathable ( const Point2D point) const
pure virtual

Returns 'true' if the given point on the terrain is pathable. This does not.

<

Parameters
pointPosition to sample.
Returns
Pathable.
virtual bool sc2::ObservationInterface::IsPlacable ( const Point2D point) const
pure virtual

Returns 'true' if the given point on the terrain is buildable. This does not.

<

Parameters
pointPosition to sample.
Returns
Placable.
virtual float sc2::ObservationInterface::TerrainHeight ( const Point2D point) const
pure virtual

Returns terrain height of the given point.

Parameters
pointPosition to sample.
Returns
Height.

The documentation for this class was generated from the following file: