BWAPI
|
00001 #ifndef __BUILDPLANNER_H__ 00002 #define __BUILDPLANNER_H__ 00003 00004 #include <BWAPI.h> 00005 00006 using namespace BWAPI; 00007 using namespace std; 00008 00009 struct BuildQueueItem { 00010 UnitType toBuild; 00011 int assignedFrame; 00012 int assignedWorkerId; 00013 }; 00014 00024 class BuildPlanner { 00025 00026 private: 00027 static BuildPlanner* instance; 00028 00029 protected: 00030 BuildPlanner(); 00031 vector<UnitType> buildOrder; 00032 vector<BuildQueueItem> buildQueue; 00033 void lock(int buildOrderIndex, int unitId); 00034 bool executeOrder(UnitType type); 00035 bool shallBuildSupplyDepot(); 00036 string format(UnitType type); 00037 00038 bool hasResourcesLeft(); 00039 int mineralsNearby(TilePosition center); 00040 00041 int lastCommandCenter; 00042 00043 int lastCallFrame; 00044 00045 public: 00047 ~BuildPlanner(); 00048 00050 static BuildPlanner* getInstance(); 00051 00053 int noInProduction(UnitType type); 00054 00056 void computeActions(); 00057 00059 void buildingDestroyed(Unit* building); 00060 00066 void unlock(UnitType type); 00067 00069 void remove(UnitType type); 00070 00072 void handleWorkerDestroyed(UnitType type, int workerID); 00073 00075 void commandCenterBuilt(); 00076 00078 void printInfo(); 00079 00082 void handleNoBuildspotFound(UnitType toBuild); 00083 00085 bool shallBuildSupply(); 00086 00088 bool supplyBeingBuilt(); 00089 00092 bool nextIsOfType(UnitType type); 00093 00095 bool containsType(UnitType type); 00096 00098 void addBuilding(UnitType type); 00099 00101 void addBuildingFirst(UnitType type); 00102 00104 void expand(UnitType commandCenterUnit); 00105 00107 void addRefinery(); 00108 00110 static bool coveredByDetector(TilePosition pos); 00111 00113 bool executeMorph(UnitType target, UnitType evolved); 00114 00116 static bool isTerran(); 00117 00119 static bool isProtoss(); 00120 00122 static bool isZerg(); 00123 }; 00124 00125 #endif