|
ProtoBot
|
The SpenderManager is the way ProtoBot is able to reserve the resouces ProtoBot wants to spend and approve the requests of units ProtoBot is able to make.
This prevents ProtoBot from spending resoucres that ahve already been allocated to another request and allows ProtoBot to make decisions based on what it has already made.
More...
#include <SpenderManager.h>
Public Member Functions | |
| bool | canAfford (int mineralPrice, int gasPrice, int currentMinerals, int currentGas) |
| Given the mineral and gas cost of a unit, considering the amount of minerals and gas we mightve spent this frame, are we able to afford this unit? | |
| int | availableMinerals (std::vector< ResourceRequest > &) |
| Loops through all of ProtoBot's current ResourceRequest's and checks the amount of minerals we have already reserved for each unit compared the amount of minerals StarCraft says ProtoBot currently has. If a ResourceRequest has a State other than PendingApproval, we have already reserved the minerals for that request. | |
| int | availableGas (std::vector< ResourceRequest > &) |
| Loops through all of ProtoBot's current ResourceRequest's and checks the amount of gas we have already reserved for each unit compared the amount of gas StarCraft says ProtoBot currently has. If a ResourceRequest has a State other than PendingApproval, we have already reserved the gas for that request. | |
| int | plannedSupply (std::vector< ResourceRequest > &, BWAPI::Unitset) |
| Due to buildings having two states created and completed, this requires ProtoBot to check if we have enough supply being made already to prevent ProtoBot from being supply blocked. First ProtoBot adds up all the supply buildings and units that are approved in the ResourceRequest queue. Second a check to all the unit ProtoBot currently is accounted for. In StarCraft a building does not provide supply until it is in a completed state, to prevent ProtoBot from creating more supply when units are in a created but not completed state this second check prevents the case from happening. | |
| int | availableSupply () |
| void | printQueue () |
| void | onStart () |
| void | OnFrame (std::vector< ResourceRequest > &) |
| The queue for ProtoBot's ResourceRequest's operates in a first in first out operation, this means that ProtoBot is not able to reorganize the queue in any advance ways but does provide a structed list of units to created in their requested order. The SpenderManager simply loops through the ResourceRequest's of ProtoBot and checks what the agent is able afford. Due to prioirty not being implemented a simple first pass is ran specifically for Pylons and Worker due to the units being integral to success. After the initial first pass the queue runs normally through the pending resource requests until we can no longer afford any more units. | |
The SpenderManager is the way ProtoBot is able to reserve the resouces ProtoBot wants to spend and approve the requests of units ProtoBot is able to make.
This prevents ProtoBot from spending resoucres that ahve already been allocated to another request and allows ProtoBot to make decisions based on what it has already made.
Definition at line 14 of file SpenderManager.h.
| SpenderManager::SpenderManager | ( | ) |
Definition at line 5 of file SpenderManager.cpp.
| int SpenderManager::availableGas | ( | std::vector< ResourceRequest > & | requests | ) |
Loops through all of ProtoBot's current ResourceRequest's and checks the amount of gas we have already reserved for each unit compared the amount of gas StarCraft says ProtoBot currently has.
If a ResourceRequest has a State other than PendingApproval, we have already reserved the gas for that request.
| ProtoBot ResourceRequests |
Definition at line 47 of file SpenderManager.cpp.
| int SpenderManager::availableMinerals | ( | std::vector< ResourceRequest > & | requests | ) |
Loops through all of ProtoBot's current ResourceRequest's and checks the amount of minerals we have already reserved for each unit compared the amount of minerals StarCraft says ProtoBot currently has.
If a ResourceRequest has a State other than PendingApproval, we have already reserved the minerals for that request.
| ProtoBot ResourceRequests |
Definition at line 17 of file SpenderManager.cpp.
| int SpenderManager::availableSupply | ( | ) |
Definition at line 78 of file SpenderManager.cpp.
| bool SpenderManager::canAfford | ( | int | mineralPrice, |
| int | gasPrice, | ||
| int | currentMinerals, | ||
| int | currentGas ) |
Given the mineral and gas cost of a unit, considering the amount of minerals and gas we mightve spent this frame, are we able to afford this unit?
| mineralPrice | |
| gasPrice | |
| currentMinerals (minerals we have not spent considering the minerals we reserved) | |
| currentGas (gas we have not spent considering the gas we reserved) |
Definition at line 126 of file SpenderManager.cpp.
| void SpenderManager::OnFrame | ( | std::vector< ResourceRequest > & | requests | ) |
The queue for ProtoBot's ResourceRequest's operates in a first in first out operation, this means that ProtoBot is not able to reorganize the queue in any advance ways but does provide a structed list of units to created in their requested order.
The SpenderManager simply loops through the ResourceRequest's of ProtoBot and checks what the agent is able afford. Due to prioirty not being implemented a simple first pass is ran specifically for Pylons and Worker due to the units being integral to success.
After the initial first pass the queue runs normally through the pending resource requests until we can no longer afford any more units.
| ProtoBot ResourceRequest |
Definition at line 143 of file SpenderManager.cpp.
| void SpenderManager::onStart | ( | ) |
Definition at line 138 of file SpenderManager.cpp.
| int SpenderManager::plannedSupply | ( | std::vector< ResourceRequest > & | requests, |
| BWAPI::Unitset | buildings ) |
Due to buildings having two states created and completed, this requires ProtoBot to check if we have enough supply being made already to prevent ProtoBot from being supply blocked.
First ProtoBot adds up all the supply buildings and units that are approved in the ResourceRequest queue.
Second a check to all the unit ProtoBot currently is accounted for.
In StarCraft a building does not provide supply until it is in a completed state, to prevent ProtoBot from creating more supply when units are in a created but not completed state this second check prevents the case from happening.
| ProtoBot ResourceRequests | |
| ProtoBot units |
Definition at line 85 of file SpenderManager.cpp.
| void SpenderManager::printQueue | ( | ) |
Definition at line 10 of file SpenderManager.cpp.