TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
Base class for single-task controllers. More...
#include <controller.h>
Inherits cherrypi::ControllerBase.
Inherited by cherrypi::BuilderControllerBase.
Public Member Functions | |
Controller (Module *module) | |
virtual | ~Controller ()=default |
virtual bool | didSucceed () const |
Implement this to return whether your custom Controller did succeed in its mission (if applicable) and can be disposed. More... | |
virtual bool | didFail () const |
Implement this to return whether your custom Controller did fail in its mission (if applicable) and can be disposed. More... | |
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... | |
virtual const char * | getName () const |
A name for this Controller, for debugging purposes. More... | |
Protected Attributes | |
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_ |
Additional Inherited Members | |
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... | |
Base class for single-task controllers.
This class models a 1:1 relationship with an accompanying Task. Units are added to the controller when the respective task object (ControllerTask) is created.
Controller provides two additional virtual function that can be re-implemented by sub-classes: didSucceed() and didFail(). These will be used by the accompanying Task object to update its status. If your controller returns true for one of these functions, the accompanying Task will end and the controller is free to be disposed of and should not be stepped through any more.
A typical Module::step() function with Controller objects might look similar to this:
cherrypi::Controller::Controller | ( | Module * | module | ) |
|
virtualdefault |
|
virtual |
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 in cherrypi::BuilderControllerBase.
|
inlinevirtual |
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 in cherrypi::BuilderControllerBase.
void cherrypi::Controller::setUpcId | ( | UpcId | id | ) |
Set the UPC ID of the corresponding task.
|
protected |