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

Controls gathering workers for GathererModule. More...

#include <gathererc.h>

Inherits cherrypi::SharedController.

Public Member Functions

virtual void addUnit (State *, Unit *worker, UpcId) override
 Add a unit to this controller. More...
 
virtual void removeUnit (State *, Unit *worker, UpcId) override
 Remove a unit from this controller. More...
 
virtual bool keepUnit (State *, Unit *worker) const override
 Decide whether to keep a unit. More...
 
virtual void step (State *) override
 Advance controller state and produce UPCs. More...
 
virtual const char * getName () const override
 A name for this Controller, for debugging purposes. More...
 
- Public Member Functions inherited from cherrypi::SharedController
virtual ~SharedController ()=default
 
- Public Member Functions inherited from cherrypi::ControllerBase
 ControllerBase (Module *module)
 
virtual ~ControllerBase ()=default
 
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

void micro (State *, Unit *worker, Unit *resource)
 Decide what to do with a worker this frame. More...
 
void gather (State *, Unit *worker, Unit *resource, bool dropResources=false)
 Issue a UPC to command a worker to gather a resource. More...
 
void flee (State *, Unit *worker, Unit *resource)
 Issue a UPC to command a worker to flee. More...
 
void chase (State *, Unit *worker, Unit *target)
 Issue a UPC to command a worker to chase an enemy proxy builder, to ensure that they don't do anything sneaky out of our vision. More...
 
void attack (State *, Unit *worker, Unit *target)
 Issue a UPC to command a worker to attack a unit. More...
 
- 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

GathererAssignments assignments
 
std::vector< Unit * > proxyBuilders
 
std::vector< Unit * > proxies
 
std::vector< Unit * > invaders
 
std::vector< Unit * > bastions
 
bool wasProxied = false
 True if we have ever been proxied (an enemy attempted to build structures in or near our base. More...
 
- Protected Attributes inherited from cherrypi::ControllerBase
Modulemodule_
 
std::unordered_map< Unit *, UpcIdunits_
 
std::unordered_map< Unit *, std::pair< UpcId, std::shared_ptr< UPCTuple > > > upcs_
 

Additional Inherited Members

- Static Public Member Functions inherited from cherrypi::SharedController
template<typename T >
static std::shared_ptr< T > globalInstance (State *state, Module *module, std::string name=std::string())
 Retrieves the global instance of a shared controller. More...
 

Detailed Description

Controls gathering workers for GathererModule.

Member Function Documentation

void cherrypi::GathererController::addUnit ( State state,
Unit unit,
UpcId  id 
)
overridevirtual

Add a unit to this controller.

This is usually called whenever a new Task for a controller is being cretaed. 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::GathererController::attack ( State state,
Unit worker,
Unit target 
)
protected

Issue a UPC to command a worker to attack a unit.

void cherrypi::GathererController::chase ( State state,
Unit worker,
Unit target 
)
protected

Issue a UPC to command a worker to chase an enemy proxy builder, to ensure that they don't do anything sneaky out of our vision.

void cherrypi::GathererController::flee ( State state,
Unit worker,
Unit resource 
)
protected

Issue a UPC to command a worker to flee.

void cherrypi::GathererController::gather ( State state,
Unit worker,
Unit resource,
bool  dropResources = false 
)
protected

Issue a UPC to command a worker to gather a resource.

virtual const char* cherrypi::GathererController::getName ( ) const
inlineoverridevirtual

A name for this Controller, for debugging purposes.

Reimplemented from cherrypi::ControllerBase.

bool cherrypi::GathererController::keepUnit ( State state,
Unit unit 
) const
overridevirtual

Decide whether to keep a unit.

By default, this returns false for dead and non-allied units.

Reimplemented from cherrypi::ControllerBase.

void cherrypi::GathererController::micro ( State state,
Unit worker,
Unit resource 
)
protected

Decide what to do with a worker this frame.

void cherrypi::GathererController::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::GathererController::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.

Member Data Documentation

GathererAssignments cherrypi::GathererController::assignments
protected
std::vector<Unit*> cherrypi::GathererController::bastions
protected
std::vector<Unit*> cherrypi::GathererController::invaders
protected
std::vector<Unit*> cherrypi::GathererController::proxies
protected
std::vector<Unit*> cherrypi::GathererController::proxyBuilders
protected
bool cherrypi::GathererController::wasProxied = false
protected

True if we have ever been proxied (an enemy attempted to build structures in or near our base.


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