TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
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... | |
Unit * | getResource (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 |
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>)
Assign a worker to gathering a specific resource.
|
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?
|
inline |
End iterator for worker assignments; allows treatment as a C++ Range.
bool cherrypi::ResourceWorkers::excludeResource | ( | Unit * | resource | ) |
Disallow gathering from a resource.
To which resource (if any) is this worker assigned?
void cherrypi::ResourceWorkers::includeResource | ( | Unit * | resource | ) |
Allow gathering from a resource.
|
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.
|
protected |