TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
cherrypi::Unit Struct Reference

Represents a unit in the game. More...

#include <unitsinfo.h>

Public Member Functions

 Unit ()
 
bool flag (tc::Unit::Flags n) const
 
bool attacking () const
 
bool burrowed () const
 
bool cloaked () const
 
bool idle () const
 
bool completed () const
 
bool detected () const
 
bool morphing () const
 
bool beingGathered () const
 
bool active () const
 
bool powered () const
 
bool lifted () const
 
bool carryingMinerals () const
 
bool carryingGas () const
 
bool carryingResources () const
 
bool moving () const
 
bool upgrading () const
 
bool researching () const
 
bool blind () const
 
bool beingConstructed () const
 
bool flying () const
 
bool invincible () const
 
bool irradiated () const
 
bool plagued () const
 
bool underDarkSwarm () const
 
bool gatheringGas () const
 
bool gatheringMinerals () const
 
bool gathering () const
 
bool constructing () const
 
bool repairing () const
 
bool stimmed () const
 
bool ensnared () const
 
double atTopSpeed () const
 
bool canKite (Unit const *dest) const
 
bool canAttack (Unit const *dest) const
 
double cd () const
 
double maxCdAir () const
 
double maxCdGround () const
 
Vec2 velocity () const
 
Vec2 pxVelocity () const
 
double pxTopSpeed () const
 
double maxCdAgainst (Unit const *target) const
 
double rangeAgainst (Unit const *target) const
 
double pxRangeAgainst (Unit const *target) const
 
Position pos () const
 
Vec2 posf () const
 
bool inRangeOf (Unit const *source, double frames=0U) const
 
void computeDamageTo (Unit const *dest, int *hpDamage, int *shieldDamage) const
 Compute HP and shield damage to dest when attacking now. More...
 
void computeDamageTo (Unit const *dest, int *hpDamage, int *shieldDamage, int destShield) const
 Compute HP and shield damage to dest when attacking now and dest has destShield shield points left. More...
 
double computeEHP (Unit const *dest) const
 
double computeHPDamage (Unit const *dest, double dmg) const
 
double computeHPDamage (Unit const *dest) const
 
double computeShieldDamage (Unit const *dest, double dmg) const
 
double computeShieldDamage (Unit const *dest) const
 
Position getMovingTarget () const
 
double damageMultiplier (Unit const *dest) const
 
double damageMultiplier (int damageType, int unitSize) const
 

Public Attributes

UnitId id = -1
 
int x = 0
 
int y = 0
 
PlayerId playerId = -1
 
bool visible = false
 This unit is currently visible. More...
 
bool dead = false
 We've seen this unit die. More...
 
bool gone = false
 If the unit is not visible, but we've scouted the last location it was at, and we don't have a better clue about where it is, then this is set to true. More...
 
FrameNum firstSeen = 0
 
FrameNum lastSeen = 0
 
FrameNum goneFrame = 0
 
FrameNum lastLarvaSpawn = 0
 
bool isMine = false
 
bool isEnemy = false
 
bool isNeutral = false
 
const BuildTypetype = nullptr
 
FrameNum busyUntil = 0
 
int buildX = 0
 X coordinate of the walktile the build location (top left corner) of the unit. More...
 
int buildY = 0
 Y coordinate of the walktile the build location (top left corner) of the unit. More...
 
const BuildTypeconstructingType = nullptr
 
const BuildTypeupgradingType = nullptr
 
const BuildTyperesearchingType = nullptr
 
int remainingBuildTrainTime = 0
 
int remainingUpgradeResearchTime = 0
 
UnitassociatedUnit = nullptr
 
int associatedCount = 0
 
Unitaddon = nullptr
 
int sightRange = 0
 
UnitattackingTarget = nullptr
 
int lastAttacked = 0
 
double topSpeed = 0
 
bool hasCollision = true
 
Position lastSeenPos
 
std::unordered_set< Unit * > inferNearbyUnitsToMove
 
tc::Unit unit = {}
 A copy of the torchcraft unit data. More...
 
UpcId lastUpcId = kInvalidUpcId
 The last UPC that was used to send a TC command involving this unit. More...
 
uint32_t lastUpcCommands = Command::None
 Bitwise combination of last UPC command and all its sources. More...
 
std::vector< Unit * > threateningEnemies
 
std::vector< Unit * > beingAttackedByEnemies
 
std::vector< Unit * > unitsInSightRange
 
std::vector< Unit * > obstaclesInSightRange
 
std::vector< Unit * > enemyUnitsInSightRange
 
std::vector< Unit * > allyUnitsInSightRange
 
std::array< size_t, 16 > containerIndices
 

Static Public Attributes

static float constexpr kLastUpcCommandThreshold = 0.5f
 Commands with a probility higher than this will be considered for lastUpcCommands. More...
 
static const size_t invalidIndex = (size_t)-1
 

Detailed Description

Represents a unit in the game.

Unit objects have game lifetime. Thus, you can hold pointers to them.

Constructor & Destructor Documentation

cherrypi::Unit::Unit ( )
inline

Member Function Documentation

bool cherrypi::Unit::active ( ) const
inline
bool cherrypi::Unit::attacking ( ) const
inline
double cherrypi::Unit::atTopSpeed ( ) const
inline
bool cherrypi::Unit::beingConstructed ( ) const
inline
bool cherrypi::Unit::beingGathered ( ) const
inline
bool cherrypi::Unit::blind ( ) const
inline
bool cherrypi::Unit::burrowed ( ) const
inline
bool cherrypi::Unit::canAttack ( Unit const *  dest) const
inline
bool cherrypi::Unit::canKite ( Unit const *  dest) const
bool cherrypi::Unit::carryingGas ( ) const
inline
bool cherrypi::Unit::carryingMinerals ( ) const
inline
bool cherrypi::Unit::carryingResources ( ) const
inline
double cherrypi::Unit::cd ( ) const
bool cherrypi::Unit::cloaked ( ) const
inline
bool cherrypi::Unit::completed ( ) const
inline
void cherrypi::Unit::computeDamageTo ( Unit const *  dest,
int *  hpDamage,
int *  shieldDamage 
) const

Compute HP and shield damage to dest when attacking now.

void cherrypi::Unit::computeDamageTo ( Unit const *  dest,
int *  hpDamage,
int *  shieldDamage,
int  destShield 
) const

Compute HP and shield damage to dest when attacking now and dest has destShield shield points left.

double cherrypi::Unit::computeEHP ( Unit const *  dest) const
double cherrypi::Unit::computeHPDamage ( Unit const *  dest,
double  dmg 
) const
inline
double cherrypi::Unit::computeHPDamage ( Unit const *  dest) const
inline
double cherrypi::Unit::computeShieldDamage ( Unit const *  dest,
double  dmg 
) const
inline
double cherrypi::Unit::computeShieldDamage ( Unit const *  dest) const
inline
bool cherrypi::Unit::constructing ( ) const
inline
double cherrypi::Unit::damageMultiplier ( Unit const *  dest) const
double cherrypi::Unit::damageMultiplier ( int  damageType,
int  unitSize 
) const
bool cherrypi::Unit::detected ( ) const
inline
bool cherrypi::Unit::ensnared ( ) const
inline
bool cherrypi::Unit::flag ( tc::Unit::Flags  n) const
inline
bool cherrypi::Unit::flying ( ) const
inline
bool cherrypi::Unit::gathering ( ) const
inline
bool cherrypi::Unit::gatheringGas ( ) const
inline
bool cherrypi::Unit::gatheringMinerals ( ) const
inline
Position cherrypi::Unit::getMovingTarget ( ) const
bool cherrypi::Unit::idle ( ) const
inline
bool cherrypi::Unit::inRangeOf ( Unit const *  source,
double  frames = 0U 
) const
bool cherrypi::Unit::invincible ( ) const
inline
bool cherrypi::Unit::irradiated ( ) const
inline
bool cherrypi::Unit::lifted ( ) const
inline
double cherrypi::Unit::maxCdAgainst ( Unit const *  target) const
double cherrypi::Unit::maxCdAir ( ) const
double cherrypi::Unit::maxCdGround ( ) const
bool cherrypi::Unit::morphing ( ) const
inline
bool cherrypi::Unit::moving ( ) const
inline
bool cherrypi::Unit::plagued ( ) const
inline
Position cherrypi::Unit::pos ( ) const
inline
Vec2 cherrypi::Unit::posf ( ) const
bool cherrypi::Unit::powered ( ) const
inline
double cherrypi::Unit::pxRangeAgainst ( Unit const *  target) const
double cherrypi::Unit::pxTopSpeed ( ) const
Vec2 cherrypi::Unit::pxVelocity ( ) const
double cherrypi::Unit::rangeAgainst ( Unit const *  target) const
bool cherrypi::Unit::repairing ( ) const
inline
bool cherrypi::Unit::researching ( ) const
inline
bool cherrypi::Unit::stimmed ( ) const
inline
bool cherrypi::Unit::underDarkSwarm ( ) const
inline
bool cherrypi::Unit::upgrading ( ) const
inline
Vec2 cherrypi::Unit::velocity ( ) const

Member Data Documentation

Unit* cherrypi::Unit::addon = nullptr
std::vector<Unit*> cherrypi::Unit::allyUnitsInSightRange
int cherrypi::Unit::associatedCount = 0
Unit* cherrypi::Unit::associatedUnit = nullptr
Unit* cherrypi::Unit::attackingTarget = nullptr
std::vector<Unit*> cherrypi::Unit::beingAttackedByEnemies
int cherrypi::Unit::buildX = 0

X coordinate of the walktile the build location (top left corner) of the unit.

int cherrypi::Unit::buildY = 0

Y coordinate of the walktile the build location (top left corner) of the unit.

FrameNum cherrypi::Unit::busyUntil = 0
const BuildType* cherrypi::Unit::constructingType = nullptr
std::array<size_t, 16> cherrypi::Unit::containerIndices
bool cherrypi::Unit::dead = false

We've seen this unit die.

std::vector<Unit*> cherrypi::Unit::enemyUnitsInSightRange
FrameNum cherrypi::Unit::firstSeen = 0
bool cherrypi::Unit::gone = false

If the unit is not visible, but we've scouted the last location it was at, and we don't have a better clue about where it is, then this is set to true.

The unit might still be in the game, or it might be dead.

FrameNum cherrypi::Unit::goneFrame = 0
bool cherrypi::Unit::hasCollision = true
UnitId cherrypi::Unit::id = -1
std::unordered_set<Unit*> cherrypi::Unit::inferNearbyUnitsToMove
const size_t cherrypi::Unit::invalidIndex = (size_t)-1
static
bool cherrypi::Unit::isEnemy = false
bool cherrypi::Unit::isMine = false
bool cherrypi::Unit::isNeutral = false
float constexpr cherrypi::Unit::kLastUpcCommandThreshold = 0.5f
static

Commands with a probility higher than this will be considered for lastUpcCommands.

int cherrypi::Unit::lastAttacked = 0
FrameNum cherrypi::Unit::lastLarvaSpawn = 0
FrameNum cherrypi::Unit::lastSeen = 0
Position cherrypi::Unit::lastSeenPos
uint32_t cherrypi::Unit::lastUpcCommands = Command::None

Bitwise combination of last UPC command and all its sources.

UpcId cherrypi::Unit::lastUpcId = kInvalidUpcId

The last UPC that was used to send a TC command involving this unit.

std::vector<Unit*> cherrypi::Unit::obstaclesInSightRange
PlayerId cherrypi::Unit::playerId = -1
int cherrypi::Unit::remainingBuildTrainTime = 0
int cherrypi::Unit::remainingUpgradeResearchTime = 0
const BuildType* cherrypi::Unit::researchingType = nullptr
int cherrypi::Unit::sightRange = 0
std::vector<Unit*> cherrypi::Unit::threateningEnemies
double cherrypi::Unit::topSpeed = 0
const BuildType* cherrypi::Unit::type = nullptr
tc::Unit cherrypi::Unit::unit = {}

A copy of the torchcraft unit data.

std::vector<Unit*> cherrypi::Unit::unitsInSightRange
const BuildType* cherrypi::Unit::upgradingType = nullptr
bool cherrypi::Unit::visible = false

This unit is currently visible.

If this field is set, all other fields are up-to-date, otherwise everything is from when we last saw it.

int cherrypi::Unit::x = 0
int cherrypi::Unit::y = 0

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