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

Data structure for storing the state of our gathering assignments. More...

#include <resourceworkers.h>

Public Member Functions

void assignWorker (Unit *worker, Unit *resource)
 Assign a worker to gathering a specific resource. More...
 
void unassignWorker (Unit *worker)
 Remove a worker from gathering and any resources it might be assigned to. More...
 
void includeResource (Unit *resource)
 Allow gathering from a resource. More...
 
bool excludeResource (Unit *resource)
 Disallow gathering from a resource. More...
 
bool containsResource (Unit *resource)
 Is this resource currently included in gathering? More...
 
UnitgetResource (Unit *worker) const
 To which resource (if any) is this worker assigned? More...
 
size_t countWorkers (Unit *resource) const
 How many workers are assigned to this resource? More...
 
auto begin ()
 Start iterator for worker assignments; allows treatment as a C++ Range. More...
 
auto end ()
 End iterator for worker assignments; allows treatment as a C++ Range. More...
 
size_t size ()
 For how many resources is gathering enabled? More...
 

Protected Attributes

std::unordered_map< Unit *, Unit * > resourceByWorker
 
std::unordered_map< Unit *, std::unordered_set< Unit * > > workersByResource
 

Detailed Description

Data structure for storing the state of our gathering assignments.

Enforces the bidirectional mapping of (Worker -> Resource) and (Resource -> Set<Workers>)

Iterable as a C++ Range over (Resource -> Set<Workers>)

Member Function Documentation

void cherrypi::ResourceWorkers::assignWorker ( Unit worker,
Unit resource 
)

Assign a worker to gathering a specific resource.

auto cherrypi::ResourceWorkers::begin ( )
inline

Start iterator for worker assignments; allows treatment as a C++ Range.

bool cherrypi::ResourceWorkers::containsResource ( Unit resource)

Is this resource currently included in gathering?

size_t cherrypi::ResourceWorkers::countWorkers ( Unit resource) const

How many workers are assigned to this resource?

auto cherrypi::ResourceWorkers::end ( )
inline

End iterator for worker assignments; allows treatment as a C++ Range.

bool cherrypi::ResourceWorkers::excludeResource ( Unit resource)

Disallow gathering from a resource.

Unit * cherrypi::ResourceWorkers::getResource ( Unit worker) const

To which resource (if any) is this worker assigned?

void cherrypi::ResourceWorkers::includeResource ( Unit resource)

Allow gathering from a resource.

size_t cherrypi::ResourceWorkers::size ( )
inline

For how many resources is gathering enabled?

void cherrypi::ResourceWorkers::unassignWorker ( Unit worker)

Remove a worker from gathering and any resources it might be assigned to.

Member Data Documentation

std::unordered_map<Unit*, Unit*> cherrypi::ResourceWorkers::resourceByWorker
protected
std::unordered_map<Unit*, std::unordered_set<Unit*> > cherrypi::ResourceWorkers::workersByResource
protected

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