TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
A very simple build order which builds a fixed list of targets and then stops. More...
#include <autobuild.h>
Inherits cherrypi::AutoBuildTask.
Classes | |
struct | Target |
Public Member Functions | |
DefaultAutoBuildTask (int upcId, State *state, Module *module, std::vector< Target > targets) | |
virtual | ~DefaultAutoBuildTask () override |
virtual void | buildStep (autobuild::BuildState &st) override |
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) |
virtual void | preBuild (autobuild::BuildState &st) |
One of the three steps of processing a build order. More... | |
virtual void | postBuild (autobuild::BuildState &st) |
The final step of processing a build order. More... | |
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::BuildState & | lastEvaluateCurrentState () |
autobuild::BuildState & | lastEvaluateTargetState () |
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 | |
std::vector< Target > | targets |
Public Attributes inherited from cherrypi::AutoBuildTask | |
int | lastEvaluate = 0 |
autobuild::BuildState | initialBuildState |
autobuild::BuildState | currentBuildState |
State * | state_ = 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 |
Additional Inherited Members | |
Protected Member Functions inherited from cherrypi::AutoBuildTask | |
virtual void | draw (State *state) |
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... | |
Protected Attributes inherited from cherrypi::MultiProxyTask | |
std::vector< UpcId > | targetUpcIds_ |
std::vector< std::shared_ptr< Task > > | targets_ |
std::unordered_set< Unit * > | proxiedUnits_ |
std::map< TaskStatus, ProxyPolicy > | policy_ |
TaskStatus | defaultTargetStatus_ = TaskStatus::Unknown |
A very simple build order which builds a fixed list of targets and then stops.
Intended for testing purposes.
|
inline |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
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.
std::vector<Target> cherrypi::DefaultAutoBuildTask::targets |