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

#include <base.h>

Inherits cherrypi::AutoBuildTask.

Inherited by cherrypi::ABBO10HatchLing, cherrypi::ABBO12HatchHydras, cherrypi::ABBO12PoolMuta, cherrypi::ABBO2BaseMutas, cherrypi::ABBO2HatchMuta, cherrypi::ABBO3BasePoolLings, cherrypi::ABBO5Pool, cherrypi::ABBO9PoolSpeedLingMuta, cherrypi::ABBOdelayed4Pool, cherrypi::ABBOhydracheese, cherrypi::ABBOhydras, cherrypi::ABBOmidmassling, cherrypi::ABBOpve2gate1012, cherrypi::ABBOpve4gate, cherrypi::ABBOpvp2gatedt, cherrypi::ABBOpvpgategateobs, cherrypi::ABBOpvzffe5gategoon, cherrypi::ABBOt5rax, cherrypi::ABBOtvpjoyorush, cherrypi::ABBOtvtz2portwraith, cherrypi::ABBOultras, cherrypi::ABBOzve9poolspeed, cherrypi::ABBOzvp10hatch, cherrypi::ABBOzvp3hatchhydra, cherrypi::ABBOzvp6hatchhydra, cherrypi::ABBOzvpmutas, cherrypi::ABBOzvpoverpoolbase, cherrypi::ABBOzvt2basehivebase, cherrypi::ABBOzvt3hatchlurker, cherrypi::ABBOzvtantimech, cherrypi::ABBOzvtMacro, cherrypi::ABBOzvtp1hatchlurker, cherrypi::ABBOzvz12poolhydras, cherrypi::ABBOzvz9gas10pool, cherrypi::ABBOzvz9poolspeed, cherrypi::ABBOzvzoverpool, and cherrypi::ABBOzvzoverpoolplus1.

Public Member Functions

 ABBOBase (UpcId upcId, State *state, Module *module)
 
void findNaturalDefencePos (State *)
 
Position getStaticDefencePos (State *, const BuildType *type)
 
void buildSunkens (autobuild::BuildState &st, int n, Position={}, bool morphFirst=false)
 
void buildSpores (autobuild::BuildState &st, int n, Position={}, bool morphFirst=false)
 
void morphSunkens (autobuild::BuildState &, int n=1000)
 
void morphSpores (autobuild::BuildState &, int n=1000)
 
void takeNBases (autobuild::BuildState &, int n)
 
void expand (autobuild::BuildState &st)
 
void calculateArmySupply (const autobuild::BuildState &st)
 
Position findHatcheryPosNear (Position seedPos)
 
Position findSunkenPosNear (const BuildType *type, Position seedPos, bool coverMineralsOnly=false)
 
Position findSunkenPos (const BuildType *type, bool mainBaseOnly=false, bool coverMineralsOnly=false)
 
virtual void preBuild2 (autobuild::BuildState &st)
 
virtual void preBuild (autobuild::BuildState &st) overridefinal
 One of the three steps of processing a build order. More...
 
virtual void postBuild2 (autobuild::BuildState &st)
 
virtual void postBuild (autobuild::BuildState &st) overridefinal
 The final step of processing a build order. More...
 
virtual void buildStep2 (autobuild::BuildState &)
 
virtual void buildStep (autobuild::BuildState &) overridefinal
 The meat of a build order lives in buildStep(). More...
 
- Public Member Functions inherited from cherrypi::AutoBuildTask
void postBlackboardKey (std::string const &key, Blackboard::Data const &data)
 
bool cancelGas ()
 
 AutoBuildTask (int upcId, State *state, Module *module)
 
virtual ~AutoBuildTask () override
 
virtual void update (State *state) override
 
void evaluate (State *state, Module *module)
 
void simEvaluateFor (autobuild::BuildState &st, FrameNum frames)
 
void build (const BuildType *type, Position pos, std::function< void()> builtCallback)
 Builds a building at a specific position. More...
 
void build (const BuildType *type, std::function< void()> builtCallback)
 Builds a unit/building, upgrade, or technology. More...
 
void build (const BuildType *type, Position pos)
 Builds a building at a specific position. More...
 
void build (const BuildType *type)
 Builds a unit/building, upgrade, or technology. More...
 
bool buildN (const BuildType *type, int n)
 Builds up to N of a unit/building. More...
 
bool buildN (const BuildType *type, int n, int simultaneous)
 Builds up to N of a unit/building, with an optional limit on how many to build consecutively. More...
 
bool buildN (const BuildType *type, int n, Position positionIfWeBuildMore)
 Builds up to N of a building, specifying a position for the next new building. More...
 
bool upgrade (const BuildType *type)
 Researches an Upgrade or Tech Enqueues any required but missing prerequisites (like adding a Lair if you request Lurker Aspect). More...
 
autobuild::BuildStatelastEvaluateCurrentState ()
 
autobuild::BuildStatelastEvaluateTargetState ()
 
- Public Member Functions inherited from cherrypi::MultiProxyTask
 MultiProxyTask (std::vector< UpcId > targetUpcIds, UpcId upcId)
 
virtual ~MultiProxyTask ()=default
 
void setPolicyForStatus (TaskStatus status, ProxyPolicy policy)
 
virtual void cancel (State *state) override
 
virtual std::unordered_set< Unit * > const & proxiedUnits () const override
 A set of units occupied performing this task. More...
 
std::vector< std::shared_ptr< Task > > targets () const
 
- Public Member Functions inherited from cherrypi::Task
 Task (UpcId upcId, std::unordered_set< Unit * > units={})
 
virtual ~Task ()
 
TaskStatus status () const
 
void setStatus (TaskStatus status)
 
bool finished () const
 
UpcId upcId () const
 UPC id in Blackboard that caused this Task to be spawned. More...
 
std::unordered_set< Unit * > const & units () const
 A set of units occupied performing this task. More...
 
void removeUnit (Unit *unit)
 
virtual const char * getName () const
 A name for this task, for debugging purposes. More...
 

Public Attributes

Position nextBase
 
bool canExpand = false
 
bool shouldExpand = false
 
bool forceExpand = false
 
bool preferSafeExpansions = true
 
int enemyWorkerCount = 0
 
int enemyGasCount = 0
 
int enemyZealotCount = 0
 
int enemyDragoonCount = 0
 
int enemyDarkTemplarCount = 0
 
int enemyHighTemplarCount = 0
 
int enemyArchonCount = 0
 
int enemyReaverCount = 0
 
int enemyVultureCount = 0
 
int enemyGoliathCount = 0
 
int enemyTankCount = 0
 
int enemyMissileTurretCount = 0
 
int enemyCorsairCount = 0
 
int enemyScoutCount = 0
 
int enemyObserverCount = 0
 
int enemyWraithCount = 0
 
int enemyValkyrieCount = 0
 
int enemyBattlecruiserCount = 0
 
int enemyStaticDefenceCount = 0
 
int enemyBarracksCount = 0
 
int enemyRefineryCount = 0
 
int enemyAcademyCount = 0
 
int enemyGatewayCount = 0
 
int enemyCyberneticsCoreCount = 0
 
int enemyStargateCount = 0
 
int enemyForgeCount = 0
 
int enemyZerglingCount = 0
 
int enemyHydraliskCount = 0
 
int enemyMutaliskCount = 0
 
int enemyScourgeCount = 0
 
int enemySunkenCount = 0
 
int enemySporeCount = 0
 
int enemyMarineCount = 0
 
int enemyMedicCount = 0
 
int enemyFirebatCount = 0
 
int enemyFactoryCount = 0
 
int enemyLairCount = 0
 
int enemySpireCount = 0
 
int enemyCloakedUnitCount = 0
 
bool enemyHasExpanded = false
 
bool enemyIsRushing = false
 
int enemyBuildingCount = 0
 
int enemyScienceVesselCount = 0
 
int enemyArbiterCount = 0
 
int enemyShuttleCount = 0
 
int enemyResourceDepots = 0
 
int enemyGasUnits = 0
 
int enemyTemplarArchivesCount = 0
 
int myCompletedHatchCount = 0
 
int myLarvaCount = 0
 
int mySunkenCount = 0
 
int mySporeCount = 0
 
int myDroneCount = 0
 
int myZerglingCount = 0
 
int myHydraliskCount = 0
 
int myMutaliskCount = 0
 
int myScourgeCount = 0
 
int myLurkerCount = 0
 
int myGuardianCount = 0
 
int myUltraliskCount = 0
 
int myDefilerCount = 0
 
int mineralFields = 0
 
int geysers = 0
 
Position homePosition
 
Position naturalPos
 
Position naturalDefencePos
 
Position mainNaturalChoke
 
Position enemyBasePos
 
bool hasFoundEnemyBase = false
 
Position nextStaticDefencePos
 
bool weArePlanningExpansion = false
 
int currentFrame = 0
 
int bases = 0
 
bool isLosingAnOverlord = false
 
Position lastFindNaturalDefencePosEnemyPos {-1, -1}
 
std::vector< uint8_t > inBaseArea
 
FrameNum lastUpdateInBaseArea = 0
 
double armySupply = 0.0
 
double groundArmySupply = 0.0
 
double airArmySupply = 0.0
 
double enemySupplyInOurBase = 0.0
 
double enemyArmySupplyInOurBase = 0.0
 
double enemyArmySupply = 0.0
 
double enemyGroundArmySupply = 0.0
 
double enemyAirArmySupply = 0.0
 
double enemyAntiAirArmySupply = 0.0
 
double enemyAttackingArmySupply = 0.0
 
double enemyAttackingGroundArmySupply = 0.0
 
double enemyAttackingAirArmySupply = 0.0
 
int enemyAttackingWorkerCount = 0
 
double enemyLargeArmySupply = 0.0
 
double enemySmallArmySupply = 0.0
 
double enemyBiologicalArmySupply = 0.0
 
double enemyProximity = 0.0
 
int enemyProxyBuildingCount = 0
 
int enemyProxyGatewayCount = 0
 
int enemyProxyBarracksCount = 0
 
int enemyProxyForgeCount = 0
 
int enemyProxyCannonCount = 0
 
bool enemyForgeIsSpinning = false
 
tc::BW::Race enemyRace = tc::BW::Race::Unknown
 
bool autoExpand = true
 
bool autoUpgrade = true
 
bool expandNearest = false
 
bool buildExtraOverlordsIfLosingThem = true
 
- Public Attributes inherited from cherrypi::AutoBuildTask
int lastEvaluate = 0
 
autobuild::BuildState initialBuildState
 
autobuild::BuildState currentBuildState
 
Statestate_ = nullptr
 
bool isSimulation = false
 
std::unordered_map< UpcId, std::tuple< autobuild::BuildEntry, float > > scheduledUpcs
 Each of these UPCs is being proxied by this task. More...
 
std::function< bool(autobuild::BuildState &)> queue
 

Protected Member Functions

virtual void draw (State *state) override
 Draws any debugging information to the screen. More...
 
- Protected Member Functions inherited from cherrypi::MultiProxyTask
bool matchStatus (TaskStatus status)
 
- Protected Member Functions inherited from cherrypi::Task
std::unordered_set< Unit * > & units ()
 
virtual void removeDeadOrReassignedUnits (State *state)
 Remove units that have been assigned to another task and units that have died. More...
 

Additional Inherited Members

- Protected Attributes inherited from cherrypi::MultiProxyTask
std::vector< UpcIdtargetUpcIds_
 
std::vector< std::shared_ptr< Task > > targets_
 
std::unordered_set< Unit * > proxiedUnits_
 
std::map< TaskStatus, ProxyPolicypolicy_
 
TaskStatus defaultTargetStatus_ = TaskStatus::Unknown
 

Constructor & Destructor Documentation

cherrypi::ABBOBase::ABBOBase ( UpcId  upcId,
State state,
Module module 
)
inline

Member Function Documentation

void cherrypi::ABBOBase::buildSpores ( autobuild::BuildState st,
int  n,
Position  position = {},
bool  morphFirst = false 
)
void cherrypi::ABBOBase::buildStep ( autobuild::BuildState st)
finaloverridevirtual

The meat of a build order lives in buildStep().

This is where you decide what to build, and in what order.

Here's how buildStep() works:

After preBuild(), AutoBuildTask invokes buildStep() with a BuildState reflecting the current state of the game. That includes the amount of minerals, gas, and supply you have. It also has an empty queue of things to build.

In your implementation of buildStep(), you can specify everything you want to build, via methods like build() and upgrade(). These methods add your requested items to the queue in BuildState.

However, only the last request which would modify the queue actually modifies the BuildState. This request goes to the end of the build queue. The BuildState updates to reflect the request: minerals/gas is spent, supply is updated, etc.

Then, if anything was changed, buildStep() is invoked again with the new BuildState. The last request from the previous build is now reflected in the new BuildState. For example, if you have no Spawning Pool, and the last request was buildN(Spawning_Pool, 1), the BuildState will now contain the Spawning Pool you requested.

This continues until either the queue has reached a certain length (several minutes into the future) or all requests are enqueued.

Reimplemented from cherrypi::AutoBuildTask.

virtual void cherrypi::ABBOBase::buildStep2 ( autobuild::BuildState )
inlinevirtual
void cherrypi::ABBOBase::buildSunkens ( autobuild::BuildState st,
int  n,
Position  position = {},
bool  morphFirst = false 
)
void cherrypi::ABBOBase::calculateArmySupply ( const autobuild::BuildState st)
void cherrypi::ABBOBase::draw ( State state)
overrideprotectedvirtual

Draws any debugging information to the screen.

Reimplemented from cherrypi::AutoBuildTask.

void cherrypi::ABBOBase::expand ( autobuild::BuildState st)
Position cherrypi::ABBOBase::findHatcheryPosNear ( Position  seedPos)
void cherrypi::ABBOBase::findNaturalDefencePos ( State state)
Position cherrypi::ABBOBase::findSunkenPos ( const BuildType type,
bool  mainBaseOnly = false,
bool  coverMineralsOnly = false 
)
Position cherrypi::ABBOBase::findSunkenPosNear ( const BuildType type,
Position  seedPos,
bool  coverMineralsOnly = false 
)
Position cherrypi::ABBOBase::getStaticDefencePos ( State state,
const BuildType type 
)
void cherrypi::ABBOBase::morphSpores ( autobuild::BuildState st,
int  n = 1000 
)
void cherrypi::ABBOBase::morphSunkens ( autobuild::BuildState st,
int  n = 1000 
)
void cherrypi::ABBOBase::postBuild ( autobuild::BuildState st)
finaloverridevirtual

The final step of processing a build order.

postBuild() is invoked after the last invocation of buildStep().

Reimplemented from cherrypi::AutoBuildTask.

virtual void cherrypi::ABBOBase::postBuild2 ( autobuild::BuildState st)
inlinevirtual
void cherrypi::ABBOBase::preBuild ( autobuild::BuildState st)
finaloverridevirtual

One of the three steps of processing a build order.

preBuild() is invoked once before stepping through the build order.

Because it's invoked exactly once (unlike buildStep() which is invoked repeatedly) preBuild is a good place for making decisions that don't directly involve the build queue, like deciding whether to attack or deciding whether to mine gas.

Reimplemented from cherrypi::AutoBuildTask.

virtual void cherrypi::ABBOBase::preBuild2 ( autobuild::BuildState st)
inlinevirtual
void cherrypi::ABBOBase::takeNBases ( autobuild::BuildState st,
int  n 
)

Member Data Documentation

double cherrypi::ABBOBase::airArmySupply = 0.0
double cherrypi::ABBOBase::armySupply = 0.0
bool cherrypi::ABBOBase::autoExpand = true
bool cherrypi::ABBOBase::autoUpgrade = true
int cherrypi::ABBOBase::bases = 0
bool cherrypi::ABBOBase::buildExtraOverlordsIfLosingThem = true
bool cherrypi::ABBOBase::canExpand = false
int cherrypi::ABBOBase::currentFrame = 0
int cherrypi::ABBOBase::enemyAcademyCount = 0
double cherrypi::ABBOBase::enemyAirArmySupply = 0.0
double cherrypi::ABBOBase::enemyAntiAirArmySupply = 0.0
int cherrypi::ABBOBase::enemyArbiterCount = 0
int cherrypi::ABBOBase::enemyArchonCount = 0
double cherrypi::ABBOBase::enemyArmySupply = 0.0
double cherrypi::ABBOBase::enemyArmySupplyInOurBase = 0.0
double cherrypi::ABBOBase::enemyAttackingAirArmySupply = 0.0
double cherrypi::ABBOBase::enemyAttackingArmySupply = 0.0
double cherrypi::ABBOBase::enemyAttackingGroundArmySupply = 0.0
int cherrypi::ABBOBase::enemyAttackingWorkerCount = 0
int cherrypi::ABBOBase::enemyBarracksCount = 0
Position cherrypi::ABBOBase::enemyBasePos
int cherrypi::ABBOBase::enemyBattlecruiserCount = 0
double cherrypi::ABBOBase::enemyBiologicalArmySupply = 0.0
int cherrypi::ABBOBase::enemyBuildingCount = 0
int cherrypi::ABBOBase::enemyCloakedUnitCount = 0
int cherrypi::ABBOBase::enemyCorsairCount = 0
int cherrypi::ABBOBase::enemyCyberneticsCoreCount = 0
int cherrypi::ABBOBase::enemyDarkTemplarCount = 0
int cherrypi::ABBOBase::enemyDragoonCount = 0
int cherrypi::ABBOBase::enemyFactoryCount = 0
int cherrypi::ABBOBase::enemyFirebatCount = 0
int cherrypi::ABBOBase::enemyForgeCount = 0
bool cherrypi::ABBOBase::enemyForgeIsSpinning = false
int cherrypi::ABBOBase::enemyGasCount = 0
int cherrypi::ABBOBase::enemyGasUnits = 0
int cherrypi::ABBOBase::enemyGatewayCount = 0
int cherrypi::ABBOBase::enemyGoliathCount = 0
double cherrypi::ABBOBase::enemyGroundArmySupply = 0.0
bool cherrypi::ABBOBase::enemyHasExpanded = false
int cherrypi::ABBOBase::enemyHighTemplarCount = 0
int cherrypi::ABBOBase::enemyHydraliskCount = 0
bool cherrypi::ABBOBase::enemyIsRushing = false
int cherrypi::ABBOBase::enemyLairCount = 0
double cherrypi::ABBOBase::enemyLargeArmySupply = 0.0
int cherrypi::ABBOBase::enemyMarineCount = 0
int cherrypi::ABBOBase::enemyMedicCount = 0
int cherrypi::ABBOBase::enemyMissileTurretCount = 0
int cherrypi::ABBOBase::enemyMutaliskCount = 0
int cherrypi::ABBOBase::enemyObserverCount = 0
double cherrypi::ABBOBase::enemyProximity = 0.0
int cherrypi::ABBOBase::enemyProxyBarracksCount = 0
int cherrypi::ABBOBase::enemyProxyBuildingCount = 0
int cherrypi::ABBOBase::enemyProxyCannonCount = 0
int cherrypi::ABBOBase::enemyProxyForgeCount = 0
int cherrypi::ABBOBase::enemyProxyGatewayCount = 0
tc::BW::Race cherrypi::ABBOBase::enemyRace = tc::BW::Race::Unknown
int cherrypi::ABBOBase::enemyReaverCount = 0
int cherrypi::ABBOBase::enemyRefineryCount = 0
int cherrypi::ABBOBase::enemyResourceDepots = 0
int cherrypi::ABBOBase::enemyScienceVesselCount = 0
int cherrypi::ABBOBase::enemyScourgeCount = 0
int cherrypi::ABBOBase::enemyScoutCount = 0
int cherrypi::ABBOBase::enemyShuttleCount = 0
double cherrypi::ABBOBase::enemySmallArmySupply = 0.0
int cherrypi::ABBOBase::enemySpireCount = 0
int cherrypi::ABBOBase::enemySporeCount = 0
int cherrypi::ABBOBase::enemyStargateCount = 0
int cherrypi::ABBOBase::enemyStaticDefenceCount = 0
int cherrypi::ABBOBase::enemySunkenCount = 0
double cherrypi::ABBOBase::enemySupplyInOurBase = 0.0
int cherrypi::ABBOBase::enemyTankCount = 0
int cherrypi::ABBOBase::enemyTemplarArchivesCount = 0
int cherrypi::ABBOBase::enemyValkyrieCount = 0
int cherrypi::ABBOBase::enemyVultureCount = 0
int cherrypi::ABBOBase::enemyWorkerCount = 0
int cherrypi::ABBOBase::enemyWraithCount = 0
int cherrypi::ABBOBase::enemyZealotCount = 0
int cherrypi::ABBOBase::enemyZerglingCount = 0
bool cherrypi::ABBOBase::expandNearest = false
bool cherrypi::ABBOBase::forceExpand = false
int cherrypi::ABBOBase::geysers = 0
double cherrypi::ABBOBase::groundArmySupply = 0.0
bool cherrypi::ABBOBase::hasFoundEnemyBase = false
Position cherrypi::ABBOBase::homePosition
std::vector<uint8_t> cherrypi::ABBOBase::inBaseArea
Initial value:
bool cherrypi::ABBOBase::isLosingAnOverlord = false
Position cherrypi::ABBOBase::lastFindNaturalDefencePosEnemyPos {-1, -1}
FrameNum cherrypi::ABBOBase::lastUpdateInBaseArea = 0
Position cherrypi::ABBOBase::mainNaturalChoke
int cherrypi::ABBOBase::mineralFields = 0
int cherrypi::ABBOBase::myCompletedHatchCount = 0
int cherrypi::ABBOBase::myDefilerCount = 0
int cherrypi::ABBOBase::myDroneCount = 0
int cherrypi::ABBOBase::myGuardianCount = 0
int cherrypi::ABBOBase::myHydraliskCount = 0
int cherrypi::ABBOBase::myLarvaCount = 0
int cherrypi::ABBOBase::myLurkerCount = 0
int cherrypi::ABBOBase::myMutaliskCount = 0
int cherrypi::ABBOBase::myScourgeCount = 0
int cherrypi::ABBOBase::mySporeCount = 0
int cherrypi::ABBOBase::mySunkenCount = 0
int cherrypi::ABBOBase::myUltraliskCount = 0
int cherrypi::ABBOBase::myZerglingCount = 0
Position cherrypi::ABBOBase::naturalDefencePos
Position cherrypi::ABBOBase::naturalPos
Position cherrypi::ABBOBase::nextBase
Position cherrypi::ABBOBase::nextStaticDefencePos
bool cherrypi::ABBOBase::preferSafeExpansions = true
bool cherrypi::ABBOBase::shouldExpand = false
bool cherrypi::ABBOBase::weArePlanningExpansion = false

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