|
BWAPI
|
00001 #pragma once 00002 00003 #include <Common.h> 00004 #include "BuildOrderQueue.h" 00005 #include "BuildingManager.h" 00006 #include "StarcraftBuildOrderSearchManager.h" 00007 #include "StrategyManager.h" 00008 00009 typedef unsigned char Action; 00010 00011 class CompareWhenStarted 00012 { 00013 00014 public: 00015 00016 CompareWhenStarted() {} 00017 00018 // the sorting operator 00019 bool operator() (BWAPI::Unit * u1, BWAPI::Unit * u2) 00020 { 00021 int startedU1 = BWAPI::Broodwar->getFrameCount() - (u1->getType().buildTime() - u1->getRemainingBuildTime()); 00022 int startedU2 = BWAPI::Broodwar->getFrameCount() - (u2->getType().buildTime() - u2->getRemainingBuildTime()); 00023 return u1 > u2; 00024 00025 } 00026 }; 00027 00028 class ProductionManager 00029 { 00030 ProductionManager(); 00031 00032 static ProductionManager * instance; 00033 00034 std::map<char, MetaType> typeCharMap; 00035 std::vector< std::pair<MetaType, int> > searchGoal; 00036 00037 bool assignedWorkerForThisBuilding; 00038 bool haveLocationForThisBuilding; 00039 BWAPI::TilePosition predictedTilePosition; 00040 00041 bool contains(UnitVector & units, BWAPI::Unit * unit); 00042 void populateTypeCharMap(); 00043 00044 bool hasResources(BWAPI::UnitType type); 00045 bool canMake(BWAPI::UnitType type); 00046 bool hasNumCompletedUnitType(BWAPI::UnitType type, int num); 00047 bool meetsReservedResources(MetaType type); 00048 BWAPI::UnitType getProducer(MetaType t); 00049 00050 void testBuildOrderSearch(std::vector< std::pair<MetaType, int> > & goal); 00051 void setBuildOrder(std::vector<MetaType> & buildOrder); 00052 void createMetaType(BWAPI::Unit * producer, MetaType type); 00053 BWAPI::Unit * selectUnitOfType(BWAPI::UnitType type, bool leastTrainingTimeRemaining = true, BWAPI::Position closestTo = BWAPI::Position(0,0)); 00054 00055 BuildOrderQueue queue; 00056 void manageBuildOrderQueue(); 00057 void performCommand(BWAPI::UnitCommandType t); 00058 void printProductionInfo(int x, int y); 00059 bool canMakeNow(BWAPI::Unit * producer, MetaType t); 00060 void predictWorkerMovement(const Building & b); 00061 00062 bool detectBuildOrderDeadlock(); 00063 00064 int getFreeMinerals(); 00065 int getFreeGas(); 00066 00067 int reservedMinerals, reservedGas; 00068 00069 bool enemyCloakedDetected; 00070 bool rushDetected; 00071 00072 public: 00073 00074 static ProductionManager * getInstance(); 00075 00076 void drawQueueInformation(std::map<BWAPI::UnitType, int> & numUnits, int x, int y, int index); 00077 void update(); 00078 00079 void onUnitMorph(BWAPI::Unit * unit); 00080 void onUnitDestroy(BWAPI::Unit * unit); 00081 void onSendText(std::string text); 00082 };
1.7.6.1