BWAPI
Skynet/Skynet/SupplyManager.cpp
Go to the documentation of this file.
00001 #include "SupplyManager.h"
00002 
00003 #include "BuildOrderManager.h"
00004 #include "ResourceTracker.h"
00005 #include "TaskManager.h"
00006 
00007 void SupplyManagerClass::update()
00008 {
00009         if(!BuildOrderManager::Instance().getOrder(Order::SupplyManager))
00010                 return;
00011 
00012         const int &supplyTime = BWAPI::Broodwar->getFrameCount() + BWAPI::Broodwar->self()->getRace().getSupplyProvider().buildTime() + 150;
00013         if(ResourceTracker::Instance().totalSupplyAtTime(supplyTime) < 400)
00014         {
00015                 const int currentSupply = BWAPI::Broodwar->self()->supplyUsed();
00016                 const int &freeSupply = ResourceTracker::Instance().availableSupplyAtTime(supplyTime);
00017                 if(freeSupply <= (currentSupply > 120 ? 16 : currentSupply > 60 ? 8 : 0))
00018                 {
00019                         if(!mLastItem || mLastItem->hasDispatched() || mLastItem->hasEnded())
00020                                 mLastItem = TaskManager::Instance().build(BWAPI::Broodwar->self()->getRace().getSupplyProvider(), TaskType::Supply);
00021                 }
00022         }
00023 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines