TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
Base class for controllers used by BuilderModule. More...
#include <builderc.h>
Inherits cherrypi::Controller.
Inherited by cherrypi::BuilderController, and cherrypi::WorkerBuilderController.
Public Member Functions | |
BuilderControllerBase (Module *module, BuildType const *type, std::unordered_map< Unit *, float > unitProbs, std::shared_ptr< BuilderControllerData > bcdata) | |
virtual | ~BuilderControllerBase ()=default |
virtual const char * | getName () const override |
A name for this Controller, for debugging purposes. More... | |
float | priority () |
void | setPriority (float value) |
BuildType const * | type () |
Public Member Functions inherited from cherrypi::Controller | |
Controller (Module *module) | |
virtual | ~Controller ()=default |
void | setUpcId (UpcId id) |
Set the UPC ID of the corresponding task. More... | |
Public Member Functions inherited from cherrypi::ControllerBase | |
ControllerBase (Module *module) | |
virtual | ~ControllerBase ()=default |
virtual void | addUnit (State *state, Unit *unit, UpcId id) |
Add a unit to this controller. More... | |
virtual void | removeUnit (State *state, Unit *unit, UpcId id) |
Remove a unit from this controller. More... | |
virtual bool | keepUnit (State *state, Unit *unit) const |
Decide whether to keep a unit. More... | |
virtual void | step (State *state) |
Advance controller state and produce UPCs. More... | |
bool | isControllingUnitWith (Unit *unit, UpcId id) const |
Checks if the controller is controlling the given unit via the given UPC ID. More... | |
Protected Member Functions | |
virtual bool | didSucceed () const override |
Implement this to return whether your custom Controller did succeed in its mission (if applicable) and can be disposed. More... | |
virtual bool | didFail () const override |
Implement this to return whether your custom Controller did fail in its mission (if applicable) and can be disposed. More... | |
void | grabUnit (State *state, Unit *unit) |
void | releaseUnit (State *state, Unit *unit) |
bool | findBuilder (State *state, Position const &pos=Position()) |
auto | defaultUnitBuilderScore (State *state) |
Returns scoring function for selecting a unit to build another (non-building) unit. More... | |
auto | larvaBuilderScore (State *state, bool preferSaturation) |
Returns scoring function for selecting a unit to build a Larva-based unit. More... | |
auto | hatcheryTechBuilderScore (State *state) |
Returns scoring function for selecting a unit to morph a hatchery or lair. More... | |
bool | cancelled (State *state) const |
Protected Member Functions inherited from cherrypi::ControllerBase | |
void | postUpcs (State *state) |
Posts scheduled UPCs to the Blackboard. More... | |
template<typename... Args> | |
void | addUpc (Unit *unit, Args &&...args) |
Schedules an action (as a UPC) for the given unit which will be posted after doStep(). More... | |
Protected Attributes | |
BuildType const * | type_ |
Unit * | builder_ = nullptr |
std::unordered_map< Unit *, float > | unitProbs_ |
std::shared_ptr< BuilderControllerData > | bcdata_ |
bool | succeeded_ = false |
bool | failed_ = false |
float | priority_ |
Protected Attributes inherited from cherrypi::Controller | |
UpcId | upcId_ |
Protected Attributes inherited from cherrypi::ControllerBase | |
Module * | module_ |
std::unordered_map< Unit *, UpcId > | units_ |
std::unordered_map< Unit *, std::pair< UpcId, std::shared_ptr< UPCTuple > > > | upcs_ |
Base class for controllers used by BuilderModule.
Builder-related tasks will select a unit when they are ready for production or construction and not upon creation. Hence, relevant controllers will advertise the units they're using via currentUnits(), and the module that uses them will need to make sure that proper player-wide allocation is done after calling step().
cherrypi::BuilderControllerBase::BuilderControllerBase | ( | Module * | module, |
BuildType const * | type, | ||
std::unordered_map< Unit *, float > | unitProbs, | ||
std::shared_ptr< BuilderControllerData > | bcdata | ||
) |
|
virtualdefault |
|
protected |
|
protected |
Returns scoring function for selecting a unit to build another (non-building) unit.
|
inlineoverrideprotectedvirtual |
Implement this to return whether your custom Controller did fail in its mission (if applicable) and can be disposed.
By default, a Controller fails if it does not control any units.
Reimplemented from cherrypi::Controller.
|
inlineoverrideprotectedvirtual |
Implement this to return whether your custom Controller did succeed in its mission (if applicable) and can be disposed.
By default, this returns false.
Reimplemented from cherrypi::Controller.
|
protected |
|
inlineoverridevirtual |
A name for this Controller, for debugging purposes.
Reimplemented from cherrypi::ControllerBase.
Reimplemented in cherrypi::WorkerBuilderController.
|
protected |
Returns scoring function for selecting a unit to morph a hatchery or lair.
|
protected |
Returns scoring function for selecting a unit to build a Larva-based unit.
|
inline |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |