TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Public Member Functions | List of all members
cherrypi::State Class Reference

Game state. More...

#include <state.h>

Public Member Functions

 State (std::shared_ptr< tc::Client > client)
 
 State (State const &)=delete
 
virtual ~State ()
 
std::unordered_map< int32_t, tc::Unit * > const & units () const
 
tc::Unitunit (int32_t id) const
 
FrameNum currentFrame () const
 
float currentGameTime () const
 Current game time in seconds, assuming "fastest" speed. More...
 
FrameNum latencyFrames () const
 
PlayerId playerId () const
 
PlayerId neutralId () const
 
void setPerspective (PlayerId id)
 For replays, treat units from this player as allied units. More...
 
int mapWidth () const
 
int mapHeight () const
 
const std::string mapName () const
 
const std::string mapTitle () const
 
Rect mapRect () const
 
tc::Resources resources () const
 
Blackboardboard () const
 
BWEM::Map * map () const
 
template<typename T , typename... Args>
std::shared_ptr< T > addTracker (Args &&...args)
 
std::list< std::shared_ptr< Tracker > > const & trackers () const
 
UnitsInfounitsInfo ()
 
TilesInfotilesInfo ()
 
AreaInfoareaInfo ()
 
std::vector< std::pair< std::string, std::chrono::milliseconds > > getStateUpdateTimes () const
 
UpgradeLevel getUpgradeLevel (const BuildType *upgrade) const
 Get the current level of a given upgrade. More...
 
bool hasResearched (const BuildType *tech) const
 Check whether a given technology has been researched. More...
 
void update ()
 Updates internal mappings after the torchcraft state has been updated. More...
 
tc::BW::Race myRace () const
 Get my race as reported by the game. More...
 
PlayerId firstOpponent () const
 Get the player id of the first opponent. More...
 
tc::BW::Race raceFromClient (PlayerId playerId) const
 Get the race that the game returns, for a given player. More...
 
bool gameEnded () const
 Returns true if the game has ended. More...
 
bool won () const
 
bool lost () const
 
tc::Statetcstate ()
 The underlying TorchCraft state. More...
 
void setCollectTimers (bool collect)
 
UnitsInfounitsInfoPtr ()
 
TilesInfotilesInfoPtr ()
 
AreaInfoareaInfoPtr ()
 
void setMapHack (bool h)
 
bool mapHack ()
 

Detailed Description

Game state.

The game state serves as the main input and output for bot modules. It provides a global (player-wide) blackboard and access to the TorchCraft::State object in the form of wrapper functions and data structures.

Constructor & Destructor Documentation

cherrypi::State::State ( std::shared_ptr< tc::Client client)
explicit
cherrypi::State::State ( State const &  )
delete
cherrypi::State::~State ( )
virtual

Member Function Documentation

template<typename T , typename... Args>
std::shared_ptr<T> cherrypi::State::addTracker ( Args &&...  args)
inline
AreaInfo& cherrypi::State::areaInfo ( )
inline
AreaInfo* cherrypi::State::areaInfoPtr ( )
inline
Blackboard* cherrypi::State::board ( ) const
inline
FrameNum cherrypi::State::currentFrame ( ) const
inline
float cherrypi::State::currentGameTime ( ) const
inline

Current game time in seconds, assuming "fastest" speed.

PlayerId cherrypi::State::firstOpponent ( ) const

Get the player id of the first opponent.

bool cherrypi::State::gameEnded ( ) const

Returns true if the game has ended.

This will be the case if either player doesn't control any units for a some frames or if TorchCraft signals that the game has ended.

std::vector<std::pair<std::string, std::chrono::milliseconds> > cherrypi::State::getStateUpdateTimes ( ) const
inline
UpgradeLevel cherrypi::State::getUpgradeLevel ( const BuildType upgrade) const

Get the current level of a given upgrade.

Parameters
upgradeUpgrade for which to check the level
Returns
Level of a given upgrade
bool cherrypi::State::hasResearched ( const BuildType tech) const

Check whether a given technology has been researched.

Parameters
techTechnology to check for
Returns
true, if the technology has been researched
FrameNum cherrypi::State::latencyFrames ( ) const
inline
bool cherrypi::State::lost ( ) const
BWEM::Map* cherrypi::State::map ( ) const
inline
bool cherrypi::State::mapHack ( )
inline
int cherrypi::State::mapHeight ( ) const
inline
const std::string cherrypi::State::mapName ( ) const
inline
Rect cherrypi::State::mapRect ( ) const
inline
const std::string cherrypi::State::mapTitle ( ) const
inline
int cherrypi::State::mapWidth ( ) const
inline
tc::BW::Race cherrypi::State::myRace ( ) const

Get my race as reported by the game.

PlayerId cherrypi::State::neutralId ( ) const
inline
PlayerId cherrypi::State::playerId ( ) const
inline
tc::BW::Race cherrypi::State::raceFromClient ( PlayerId  playerId) const

Get the race that the game returns, for a given player.

tc::Resources cherrypi::State::resources ( ) const
void cherrypi::State::setCollectTimers ( bool  collect)
void cherrypi::State::setMapHack ( bool  h)
inline
void cherrypi::State::setPerspective ( PlayerId  id)

For replays, treat units from this player as allied units.

tc::State* cherrypi::State::tcstate ( )
inline

The underlying TorchCraft state.

It's recommended to access the game state via the other functions of this class instead.

TilesInfo& cherrypi::State::tilesInfo ( )
inline
TilesInfo* cherrypi::State::tilesInfoPtr ( )
inline
std::list<std::shared_ptr<Tracker> > const& cherrypi::State::trackers ( ) const
inline
tc::Unit* cherrypi::State::unit ( int32_t  id) const
inline
std::unordered_map<int32_t, tc::Unit*> const& cherrypi::State::units ( ) const
inline
UnitsInfo& cherrypi::State::unitsInfo ( )
inline
UnitsInfo* cherrypi::State::unitsInfoPtr ( )
inline
void cherrypi::State::update ( )

Updates internal mappings after the torchcraft state has been updated.

bool cherrypi::State::won ( ) const

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