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

A unit production controller for all other units. More...

#include <builderc.h>

Inherits cherrypi::BuilderControllerBase.

Public Member Functions

 BuilderController (Module *module, BuildType const *type, std::unordered_map< Unit *, float > unitProbs, std::shared_ptr< BuilderControllerData > bcdata)
 
virtual ~BuilderController ()=default
 
virtual void step (State *state) override
 Advance controller state and produce UPCs. More...
 
virtual void removeUnit (State *state, Unit *unit, UpcId id) override
 Remove a unit from this controller. More...
 
- Public Member Functions inherited from cherrypi::BuilderControllerBase
 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 bool keepUnit (State *state, Unit *unit) const
 Decide whether to keep a unit. 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

std::string logPrefix () const
 
- Protected Member Functions inherited from cherrypi::BuilderControllerBase
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...
 

Additional Inherited Members

- Protected Attributes inherited from cherrypi::BuilderControllerBase
BuildType const * type_
 
Unitbuilder_ = nullptr
 
std::unordered_map< Unit *, float > unitProbs_
 
std::shared_ptr< BuilderControllerDatabcdata_
 
bool succeeded_ = false
 
bool failed_ = false
 
float priority_
 
- Protected Attributes inherited from cherrypi::Controller
UpcId upcId_
 
- Protected Attributes inherited from cherrypi::ControllerBase
Modulemodule_
 
std::unordered_map< Unit *, UpcIdunits_
 
std::unordered_map< Unit *, std::pair< UpcId, std::shared_ptr< UPCTuple > > > upcs_
 

Detailed Description

A unit production controller for all other units.

This is used by BuilderModule.

Constructor & Destructor Documentation

cherrypi::BuilderController::BuilderController ( Module module,
BuildType const *  type,
std::unordered_map< Unit *, float >  unitProbs,
std::shared_ptr< BuilderControllerData bcdata 
)
virtual cherrypi::BuilderController::~BuilderController ( )
virtualdefault

Member Function Documentation

std::string cherrypi::BuilderController::logPrefix ( ) const
protected
void cherrypi::BuilderController::removeUnit ( State state,
Unit unit,
UpcId  id 
)
overridevirtual

Remove a unit from this controller.

This is usually called from Task::update() to remove units that were assigned to other Tasks, or for which keepUnit() returns false. Re-implement this function if you need to update internal data structures when gaining control of units but make sure to also call the base class method.

Reimplemented from cherrypi::ControllerBase.

void cherrypi::BuilderController::step ( State state)
overridevirtual

Advance controller state and produce UPCs.

This is intended to be called from Module::step() of the instantiating module. The default implementation does nothing.

Reimplemented from cherrypi::ControllerBase.


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