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

A task that tracks execution of multiple other tasks. More...

#include <task.h>

Inherits cherrypi::Task.

Inherited by cherrypi::AutoBuildTask, and cherrypi::SquadTask.

Public Member Functions

 MultiProxyTask (std::vector< UpcId > targetUpcIds, UpcId upcId)
 
virtual ~MultiProxyTask ()=default
 
void setPolicyForStatus (TaskStatus status, ProxyPolicy policy)
 
virtual void update (State *state) override
 
virtual void cancel (State *state) override
 
virtual std::unordered_set< Unit * > const & proxiedUnits () const override
 A set of units occupied performing this task. More...
 
std::vector< std::shared_ptr< Task > > targets () const
 
- Public Member Functions inherited from cherrypi::Task
 Task (UpcId upcId, std::unordered_set< Unit * > units={})
 
virtual ~Task ()
 
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 const char * getName () const
 A name for this task, for debugging purposes. More...
 

Protected Member Functions

bool matchStatus (TaskStatus status)
 
- Protected Member Functions inherited from cherrypi::Task
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...
 

Protected Attributes

std::vector< UpcIdtargetUpcIds_
 
std::vector< std::shared_ptr< Task > > targets_
 
std::unordered_set< Unit * > proxiedUnits_
 
std::map< TaskStatus, ProxyPolicypolicy_
 
TaskStatus defaultTargetStatus_ = TaskStatus::Unknown
 

Detailed Description

A task that tracks execution of multiple other tasks.

This is similar to ProxyTask but supports tracking of multiple tasks. Note that this is slightly heavier in terms of processing needs than ProxyTask. The status of the underlying tasks is mirrored according to the given policy. These are the default settings:

Status checks according to policies are evaluated in the following order: TaskStatus::Success, TaskStatus::Failure, TaskStatus::Ongoing and TaskStatus::Unknown.

Constructor & Destructor Documentation

cherrypi::MultiProxyTask::MultiProxyTask ( std::vector< UpcId targetUpcIds,
UpcId  upcId 
)
virtual cherrypi::MultiProxyTask::~MultiProxyTask ( )
virtualdefault

Member Function Documentation

void cherrypi::MultiProxyTask::cancel ( State state)
overridevirtual

Reimplemented from cherrypi::Task.

bool cherrypi::MultiProxyTask::matchStatus ( TaskStatus  status)
protected
std::unordered_set< Unit * > const & cherrypi::MultiProxyTask::proxiedUnits ( ) const
overridevirtual

A set of units occupied performing this task.

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

Reimplemented from cherrypi::Task.

void cherrypi::MultiProxyTask::setPolicyForStatus ( TaskStatus  status,
ProxyPolicy  policy 
)
std::vector<std::shared_ptr<Task> > cherrypi::MultiProxyTask::targets ( ) const
inline
void cherrypi::MultiProxyTask::update ( State state)
overridevirtual

Reimplemented from cherrypi::Task.

Reimplemented in cherrypi::SquadTask, and cherrypi::AutoBuildTask.

Member Data Documentation

TaskStatus cherrypi::MultiProxyTask::defaultTargetStatus_ = TaskStatus::Unknown
protected
std::map<TaskStatus, ProxyPolicy> cherrypi::MultiProxyTask::policy_
protected
std::unordered_set<Unit*> cherrypi::MultiProxyTask::proxiedUnits_
protected
std::vector<std::shared_ptr<Task> > cherrypi::MultiProxyTask::targets_
protected
std::vector<UpcId> cherrypi::MultiProxyTask::targetUpcIds_
protected

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