|
ProtoBot
|
A NexusEconomy is a the way we are able to assign workers to a specific Nexus to farm resources at the Resource Depots that ProtoBot has created.
[Note]
I have to admit the code structure for this is honestly terrible and is not great the way to be able to assign workers. If you are reading this and wanting to create a SC BW bot, make workers a class on their own and define a state machine for their specific behaviour and create components that are able to find optimal ways to farm, scout, and build given some extra arguments. It makes the handling of workers from different states easier and makes crashing less likely to happen if you dont have them as references else where.
More...
#include <NexusEconomy.h>
Public Member Functions | |
| NexusEconomy (BWAPI::Unit nexus, int id, EconomyManager *economyReference) | |
| void | defendWorker () |
| void | checkGasSteal () |
| void | onFrame () |
| void | printMineralWorkerCounts () |
| bool | OnUnitDestroy (BWAPI::Unit unit) |
| BWAPI::Unit | GetClosestMineralToWorker (BWAPI::Unit worker) |
| void | assignWorker (BWAPI::Unit unit) |
| void | assignWorkerBulk () |
| void | assignAssimilator (BWAPI::Unit assimilator) |
| BWAPI::Unitset | getWorkersToTransfer (int numberOfWorkersForTransfer) |
| BWAPI::Unit | getWorkerToScout () |
| BWAPI::Unit | getWorkerToBuild (BWAPI::Position locationToBuild) |
Public Attributes | |
| EconomyManager * | economyReference |
| int | nexusID |
| int | lifetime = 0 |
| int | fff = 0 |
| int | spot |
| double | dx |
| double | dy |
| double | slope |
| double | intercept |
| int | spot_to_move |
| int | offset |
| int | workerNums |
| int | attackingWorkers = 0 |
| bool | needWorkers = true |
| BWAPI::Unit | nexus |
| BWAPI::Unitset | workers |
| BWAPI::Unitset | minerals |
| BWAPI::Unitset | closestMinerals |
| BWAPI::Unit | vespeneGyser = nullptr |
| BWAPI::Unit | assimilator = nullptr |
| std::unordered_map< BWAPI::Unit, int > | resourceWorkerCount |
| std::unordered_map< BWAPI::Unit, BWAPI::Unit > | assignedResource |
| std::unordered_map< BWAPI::Unit, int > | workerOrder |
| std::unordered_map< BWAPI::Unit, Path > | workerPaths |
| int | optimalWorkerAmount |
| int | maximumWorkers |
| int | workerOverflowAmount |
A NexusEconomy is a the way we are able to assign workers to a specific Nexus to farm resources at the Resource Depots that ProtoBot has created.
[Note]
I have to admit the code structure for this is honestly terrible and is not great the way to be able to assign workers. If you are reading this and wanting to create a SC BW bot, make workers a class on their own and define a state machine for their specific behaviour and create components that are able to find optimal ways to farm, scout, and build given some extra arguments. It makes the handling of workers from different states easier and makes crashing less likely to happen if you dont have them as references else where.
Definition at line 23 of file NexusEconomy.h.
| NexusEconomy::NexusEconomy | ( | BWAPI::Unit | nexus, |
| int | id, | ||
| EconomyManager * | economyReference ) |
Definition at line 5 of file NexusEconomy.cpp.
| NexusEconomy::~NexusEconomy | ( | ) |
Definition at line 11 of file NexusEconomy.cpp.
| void NexusEconomy::assignAssimilator | ( | BWAPI::Unit | assimilator | ) |
Definition at line 423 of file NexusEconomy.cpp.
| void NexusEconomy::assignWorker | ( | BWAPI::Unit | unit | ) |
Definition at line 403 of file NexusEconomy.cpp.
| void NexusEconomy::assignWorkerBulk | ( | ) |
Definition at line 410 of file NexusEconomy.cpp.
| void NexusEconomy::checkGasSteal | ( | ) |
Definition at line 16 of file NexusEconomy.cpp.
| void NexusEconomy::defendWorker | ( | ) |
Definition at line 45 of file NexusEconomy.cpp.
| BWAPI::Unit NexusEconomy::GetClosestMineralToWorker | ( | BWAPI::Unit | worker | ) |
Definition at line 349 of file NexusEconomy.cpp.
| BWAPI::Unitset NexusEconomy::getWorkersToTransfer | ( | int | numberOfWorkersForTransfer | ) |
Definition at line 430 of file NexusEconomy.cpp.
| BWAPI::Unit NexusEconomy::getWorkerToBuild | ( | BWAPI::Position | locationToBuild | ) |
Definition at line 642 of file NexusEconomy.cpp.
| BWAPI::Unit NexusEconomy::getWorkerToScout | ( | ) |
Definition at line 553 of file NexusEconomy.cpp.
| void NexusEconomy::onFrame | ( | ) |
Definition at line 76 of file NexusEconomy.cpp.
| bool NexusEconomy::OnUnitDestroy | ( | BWAPI::Unit | unit | ) |
Definition at line 247 of file NexusEconomy.cpp.
| void NexusEconomy::printMineralWorkerCounts | ( | ) |
Definition at line 236 of file NexusEconomy.cpp.
| std::unordered_map<BWAPI::Unit, BWAPI::Unit> NexusEconomy::assignedResource |
Definition at line 50 of file NexusEconomy.h.
| BWAPI::Unit NexusEconomy::assimilator = nullptr |
Definition at line 48 of file NexusEconomy.h.
| int NexusEconomy::attackingWorkers = 0 |
Definition at line 39 of file NexusEconomy.h.
| BWAPI::Unitset NexusEconomy::closestMinerals |
Definition at line 45 of file NexusEconomy.h.
| double NexusEconomy::dx |
Definition at line 31 of file NexusEconomy.h.
| double NexusEconomy::dy |
Definition at line 32 of file NexusEconomy.h.
| EconomyManager* NexusEconomy::economyReference |
Definition at line 26 of file NexusEconomy.h.
| int NexusEconomy::fff = 0 |
Definition at line 29 of file NexusEconomy.h.
| double NexusEconomy::intercept |
Definition at line 34 of file NexusEconomy.h.
| int NexusEconomy::lifetime = 0 |
Definition at line 28 of file NexusEconomy.h.
| int NexusEconomy::maximumWorkers |
Definition at line 56 of file NexusEconomy.h.
| BWAPI::Unitset NexusEconomy::minerals |
Definition at line 44 of file NexusEconomy.h.
| bool NexusEconomy::needWorkers = true |
Definition at line 40 of file NexusEconomy.h.
| BWAPI::Unit NexusEconomy::nexus |
Definition at line 42 of file NexusEconomy.h.
| int NexusEconomy::nexusID |
Definition at line 27 of file NexusEconomy.h.
| int NexusEconomy::offset |
Definition at line 36 of file NexusEconomy.h.
| int NexusEconomy::optimalWorkerAmount |
Definition at line 55 of file NexusEconomy.h.
| std::unordered_map<BWAPI::Unit, int> NexusEconomy::resourceWorkerCount |
Definition at line 49 of file NexusEconomy.h.
| double NexusEconomy::slope |
Definition at line 33 of file NexusEconomy.h.
| int NexusEconomy::spot |
Definition at line 30 of file NexusEconomy.h.
| int NexusEconomy::spot_to_move |
Definition at line 35 of file NexusEconomy.h.
| BWAPI::Unit NexusEconomy::vespeneGyser = nullptr |
Definition at line 46 of file NexusEconomy.h.
| int NexusEconomy::workerNums |
Definition at line 38 of file NexusEconomy.h.
| std::unordered_map<BWAPI::Unit, int> NexusEconomy::workerOrder |
Definition at line 51 of file NexusEconomy.h.
| int NexusEconomy::workerOverflowAmount |
Definition at line 59 of file NexusEconomy.h.
| std::unordered_map<BWAPI::Unit, Path> NexusEconomy::workerPaths |
Definition at line 52 of file NexusEconomy.h.
| BWAPI::Unitset NexusEconomy::workers |
Definition at line 43 of file NexusEconomy.h.