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

Updates and organizes information about all the units in the game. More...

#include <unitsinfo.h>

Public Types

typedef std::vector< Unit * > Units
 

Public Member Functions

 UnitsInfo (State *state_)
 
 ~UnitsInfo ()
 
 UnitsInfo (UnitsInfo const &)=delete
 
UnitsInfooperator= (UnitsInfo const &)=delete
 
UnitgetUnit (UnitId id)
 
const UnitsmyUnitsOfType (const BuildType *type)
 Our units of a particular type (does not include dead units). More...
 
const UnitsmyCompletedUnitsOfType (const BuildType *type)
 Our completed units of a particular type (does not include dead units). More...
 
const UnitsallUnitsEver ()
 All units we've ever seen. More...
 
const UnitsliveUnits ()
 All units that are not dead. This includes gone units. More...
 
const UnitsvisibleUnits ()
 All units that are currently visible. More...
 
const UnitshiddenUnits ()
 All units that are currently not visible. More...
 
const UnitsvisibleBuildings ()
 All buildings that are currently visible. More...
 
const UnitsresourceUnits ()
 All resources (mineral fields, gas geysers + refineries) More...
 
const UnitsmyUnits ()
 All our (live) units. More...
 
const UnitsmyWorkers ()
 
const UnitsmyBuildings ()
 
const UnitsmyResourceDepots ()
 
const UnitsenemyUnits ()
 All enemy units that are not dead (includes gone units). More...
 
const UnitsvisibleEnemyUnits ()
 All enemy units that we can see right now. More...
 
const UnitsneutralUnits ()
 All neutral units that are not dead. More...
 
const UnitsgetNewUnits ()
 All units that were discovered since the previous update/step. More...
 
const UnitsgetStartedMorphingUnits ()
 All units that has started morphing to a different unit type (was not morphing last update/step). More...
 
const UnitsgetCompletedOrMorphedUnits ()
 All units that finished being built or finished morphing since the previous update/step. More...
 
const UnitsgetShowUnits ()
 All units that went from hidden to visible since the previous update/step. More...
 
const UnitsgetHideUnits ()
 All units that went from visible to hidden since the previous update/step. More...
 
const UnitsgetDestroyUnits ()
 All units that died since the previous update/step. More...
 
const UnitsmapHacked ()
 Parse the units directly from the tcstate, this is only reasonable when we have mapHack on. More...
 
const std::unordered_map< const BuildType *, int > & inferredEnemyUnitTypes ()
 
void update ()
 

Protected Member Functions

void updateUnit (Unit *, const tc::Unit &, tc::State *, bool maphack=false)
 
void updateGroups (Unit *i)
 
size_t inferPositionsUnitAtIndex (Position pos)
 
Position inferMovePosition (Position source, bool flying, int tileVisibiltyAge)
 
void inferMoveUnit (Unit *u, Position newPos)
 
void inferUpdateNearbyUnits ()
 

Protected Attributes

Statestate_ = nullptr
 
std::array< Units, 16 > unitContainers_
 
std::unordered_map< UnitId, UnitunitsMap_
 
std::unordered_map< int, std::unordered_map< const BuildType *, double > > speedMap_
 
UnitsallUnitsEver_ = unitContainers_[0]
 
UnitsliveUnits_ = unitContainers_[1]
 
UnitsvisibleUnits_ = unitContainers_[2]
 
UnitshiddenUnits_ = unitContainers_[3]
 
UnitsvisibleBuildings_ = unitContainers_[4]
 
UnitsresourceUnits_ = unitContainers_[5]
 
UnitsmyUnits_ = unitContainers_[6]
 
UnitsmyWorkers_ = unitContainers_[7]
 
UnitsmyBuildings_ = unitContainers_[8]
 
UnitsmyResourceDepots_ = unitContainers_[9]
 
UnitsenemyUnits_ = unitContainers_[10]
 
UnitsvisibleEnemyUnits_ = unitContainers_[11]
 
UnitsneutralUnits_ = unitContainers_[12]
 
std::unordered_map< int, UnitsmyUnitsOfType_
 
std::unordered_map< int, UnitsmyCompletedUnitsOfType_
 
Units newUnits_
 
Units startedMorphingUnits_
 
Units completedOrMorphedUnits_
 
Units showUnits_
 
Units hideUnits_
 
Units destroyUnits_
 
std::unordered_map< const BuildType *, int > memoizedEnemyUnitTypes_
 
std::vector< uint8_t > inferPositionsUnitAt
 
FrameNum lastInferUpdateNearbyUnits
 
std::minstd_rand rngEngine
 
std::unordered_map< UnitId, UnitmapHackUnitsMap_
 
UnitsmapHackUnits_ = unitContainers_[15]
 

Detailed Description

Updates and organizes information about all the units in the game.

Member Typedef Documentation

typedef std::vector<Unit*> cherrypi::UnitsInfo::Units

Constructor & Destructor Documentation

cherrypi::UnitsInfo::UnitsInfo ( State state_)
cherrypi::UnitsInfo::~UnitsInfo ( )
cherrypi::UnitsInfo::UnitsInfo ( UnitsInfo const &  )
delete

Member Function Documentation

const Units& cherrypi::UnitsInfo::allUnitsEver ( )
inline

All units we've ever seen.

const Units& cherrypi::UnitsInfo::enemyUnits ( )
inline

All enemy units that are not dead (includes gone units).

const Units& cherrypi::UnitsInfo::getCompletedOrMorphedUnits ( )
inline

All units that finished being built or finished morphing since the previous update/step.

const Units& cherrypi::UnitsInfo::getDestroyUnits ( )
inline

All units that died since the previous update/step.

const Units& cherrypi::UnitsInfo::getHideUnits ( )
inline

All units that went from visible to hidden since the previous update/step.

const Units& cherrypi::UnitsInfo::getNewUnits ( )
inline

All units that were discovered since the previous update/step.

const Units& cherrypi::UnitsInfo::getShowUnits ( )
inline

All units that went from hidden to visible since the previous update/step.

const Units& cherrypi::UnitsInfo::getStartedMorphingUnits ( )
inline

All units that has started morphing to a different unit type (was not morphing last update/step).

Unit * cherrypi::UnitsInfo::getUnit ( UnitId  id)
const Units& cherrypi::UnitsInfo::hiddenUnits ( )
inline

All units that are currently not visible.

Position cherrypi::UnitsInfo::inferMovePosition ( Position  source,
bool  flying,
int  tileVisibiltyAge 
)
protected
void cherrypi::UnitsInfo::inferMoveUnit ( Unit u,
Position  newPos 
)
protected
size_t cherrypi::UnitsInfo::inferPositionsUnitAtIndex ( Position  pos)
protected
const std::unordered_map< const BuildType *, int > & cherrypi::UnitsInfo::inferredEnemyUnitTypes ( )
void cherrypi::UnitsInfo::inferUpdateNearbyUnits ( )
protected
const Units& cherrypi::UnitsInfo::liveUnits ( )
inline

All units that are not dead. This includes gone units.

const UnitsInfo::Units & cherrypi::UnitsInfo::mapHacked ( )

Parse the units directly from the tcstate, this is only reasonable when we have mapHack on.

Keep in mind not all things that we precompute, like beingAttackedByEnemies, etc, are filled out in the mapHacked units.

const Units& cherrypi::UnitsInfo::myBuildings ( )
inline
const UnitsInfo::Units & cherrypi::UnitsInfo::myCompletedUnitsOfType ( const BuildType type)

Our completed units of a particular type (does not include dead units).

const Units& cherrypi::UnitsInfo::myResourceDepots ( )
inline
const Units& cherrypi::UnitsInfo::myUnits ( )
inline

All our (live) units.

const UnitsInfo::Units & cherrypi::UnitsInfo::myUnitsOfType ( const BuildType type)

Our units of a particular type (does not include dead units).

const Units& cherrypi::UnitsInfo::myWorkers ( )
inline
const Units& cherrypi::UnitsInfo::neutralUnits ( )
inline

All neutral units that are not dead.

UnitsInfo& cherrypi::UnitsInfo::operator= ( UnitsInfo const &  )
delete
const Units& cherrypi::UnitsInfo::resourceUnits ( )
inline

All resources (mineral fields, gas geysers + refineries)

void cherrypi::UnitsInfo::update ( )
void cherrypi::UnitsInfo::updateGroups ( Unit i)
protected
void cherrypi::UnitsInfo::updateUnit ( Unit u,
const tc::Unit tcu,
tc::State tcstate,
bool  maphack = false 
)
protected
const Units& cherrypi::UnitsInfo::visibleBuildings ( )
inline

All buildings that are currently visible.

const Units& cherrypi::UnitsInfo::visibleEnemyUnits ( )
inline

All enemy units that we can see right now.

const Units& cherrypi::UnitsInfo::visibleUnits ( )
inline

All units that are currently visible.

Member Data Documentation

Units& cherrypi::UnitsInfo::allUnitsEver_ = unitContainers_[0]
protected
Units cherrypi::UnitsInfo::completedOrMorphedUnits_
protected
Units cherrypi::UnitsInfo::destroyUnits_
protected
Units& cherrypi::UnitsInfo::enemyUnits_ = unitContainers_[10]
protected
Units& cherrypi::UnitsInfo::hiddenUnits_ = unitContainers_[3]
protected
Units cherrypi::UnitsInfo::hideUnits_
protected
std::vector<uint8_t> cherrypi::UnitsInfo::inferPositionsUnitAt
protected
FrameNum cherrypi::UnitsInfo::lastInferUpdateNearbyUnits
protected
Units& cherrypi::UnitsInfo::liveUnits_ = unitContainers_[1]
protected
Units& cherrypi::UnitsInfo::mapHackUnits_ = unitContainers_[15]
protected
std::unordered_map<UnitId, Unit> cherrypi::UnitsInfo::mapHackUnitsMap_
protected
std::unordered_map<const BuildType*, int> cherrypi::UnitsInfo::memoizedEnemyUnitTypes_
protected
Units& cherrypi::UnitsInfo::myBuildings_ = unitContainers_[8]
protected
std::unordered_map<int, Units> cherrypi::UnitsInfo::myCompletedUnitsOfType_
protected
Units& cherrypi::UnitsInfo::myResourceDepots_ = unitContainers_[9]
protected
Units& cherrypi::UnitsInfo::myUnits_ = unitContainers_[6]
protected
std::unordered_map<int, Units> cherrypi::UnitsInfo::myUnitsOfType_
protected
Units& cherrypi::UnitsInfo::myWorkers_ = unitContainers_[7]
protected
Units& cherrypi::UnitsInfo::neutralUnits_ = unitContainers_[12]
protected
Units cherrypi::UnitsInfo::newUnits_
protected
Units& cherrypi::UnitsInfo::resourceUnits_ = unitContainers_[5]
protected
std::minstd_rand cherrypi::UnitsInfo::rngEngine
protected
Units cherrypi::UnitsInfo::showUnits_
protected
std::unordered_map<int, std::unordered_map<const BuildType*, double> > cherrypi::UnitsInfo::speedMap_
protected
Units cherrypi::UnitsInfo::startedMorphingUnits_
protected
State* cherrypi::UnitsInfo::state_ = nullptr
protected
std::array<Units, 16> cherrypi::UnitsInfo::unitContainers_
protected
std::unordered_map<UnitId, Unit> cherrypi::UnitsInfo::unitsMap_
protected
Units& cherrypi::UnitsInfo::visibleBuildings_ = unitContainers_[4]
protected
Units& cherrypi::UnitsInfo::visibleEnemyUnits_ = unitContainers_[11]
protected
Units& cherrypi::UnitsInfo::visibleUnits_ = unitContainers_[2]
protected

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