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

The primary way for modules to publish their activity. More...

#include <task.h>

Inherited by cherrypi::ControllerTask, cherrypi::MasterHarassTask, cherrypi::MultiProxyTask, cherrypi::ProxyTask, cherrypi::SharedControllerTask, cherrypi::SquadTask, and cherrypi::TacticsTask.

Public Member Functions

 Task (UpcId upcId, std::unordered_set< Unit * > units={})
 
virtual ~Task ()
 
virtual void update (State *)
 
virtual void cancel (State *)
 
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 std::unordered_set< Unit * > const & proxiedUnits () const
 A set of units occupied performing this task. More...
 
virtual const char * getName () const
 A name for this task, for debugging purposes. More...
 

Protected Member Functions

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...
 

Detailed Description

The primary way for modules to publish their activity.

A task describes a particular activity of a module, likely spanning multiple frames in the game. Tasks are meant for publishing module activity to the blackboard. A typical use case would be that a given Module B acts on a UPCTuple from Module A on the blackboard (i.e. it consumes it) and spawns a corresponding task and possible further UPCTuples for lower-level Module objects. Tasks are publicly available on the blackboard, which allows Module A to track the execution of the UPCTuple that it spawned previously.

Modules are encouraged to sub-class Task and add custom, task-specific data. This way, module state is stored on the blackboard instead of in the modules themselves.

Constructor & Destructor Documentation

cherrypi::Task::Task ( UpcId  upcId,
std::unordered_set< Unit * >  units = {} 
)
inlineexplicit
virtual cherrypi::Task::~Task ( )
inlinevirtual

Member Function Documentation

void cherrypi::Task::cancel ( State state)
virtual
bool cherrypi::Task::finished ( ) const
inline
virtual const char* cherrypi::Task::getName ( ) const
inlinevirtual
virtual std::unordered_set<Unit*> const& cherrypi::Task::proxiedUnits ( ) const
inlinevirtual

A set of units occupied performing this task.

If this is a ProxyTask, this will reflect the units of the targeted task.

Reimplemented in cherrypi::MultiProxyTask, and cherrypi::ProxyTask.

void cherrypi::Task::removeDeadOrReassignedUnits ( State state)
protectedvirtual

Remove units that have been assigned to another task and units that have died.

void cherrypi::Task::removeUnit ( Unit unit)
void cherrypi::Task::setStatus ( TaskStatus  status)
inline
TaskStatus cherrypi::Task::status ( ) const
inline
std::unordered_set<Unit*> const& cherrypi::Task::units ( ) const
inline

A set of units occupied performing this task.

std::unordered_set<Unit*>& cherrypi::Task::units ( )
inlineprotected
UpcId cherrypi::Task::upcId ( ) const
inline

UPC id in Blackboard that caused this Task to be spawned.

virtual void cherrypi::Task::update ( State )
inlinevirtual

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