BWAPI
|
00001 #pragma once 00002 #include <BWAPI.h> 00003 #include <BWTA.h> 00004 #include <windows.h> 00005 #include "Common.h" 00006 00007 #define SCANNER_SWEEP_FREQUENCY 30 00008 00009 DWORD WINAPI AnalyzeMapThread(); 00010 00011 typedef std::map<BWAPI::UnitType, BWAPI::UnitType> BuildingToUnitMap; 00012 typedef std::map<BWAPI::UnitType, std::vector<BWAPI::TechType> > BuildingToTechMap; 00013 typedef std::map<BWAPI::UnitType, std::vector<BWAPI::UpgradeType> > BuildingToUpgradeMap; 00014 typedef std::map<BWAPI::UnitType, std::vector<BWAPI::UnitType> > BuildingToAddonMap; 00015 typedef std::map<BWAPI::Unit*, BWAPI::UnitType> UnitToTypeMap; 00016 typedef std::map<BWAPI::Unit*, int> UnitToTimeMap; 00017 00018 class InformationManager 00019 { 00020 public: 00021 InformationManager(); 00022 ~InformationManager(); 00023 void analyzeMap(); 00024 00025 // Economical information 00026 void reserveMinerals(int minerals); 00027 void removeReservedMinerals(int minerals); 00028 void reserveGas(int gas); 00029 void removeReservedGas(int gas); 00030 int minerals(); 00031 int gas(); 00032 bool haveResources(BWAPI::UnitType type); 00033 bool haveResources(BWAPI::TechType type); 00034 bool haveResources(BWAPI::UpgradeType type); 00035 void frameSpend(BWAPI::UnitType type); 00036 void frameSpend(BWAPI::TechType type); 00037 void frameSpend(BWAPI::UpgradeType type); 00038 int _mineralsReserved; 00039 int _gasReserved; 00040 int _frameMineralSpend; 00041 int _frameGasSpend; 00042 00043 // Build request 00044 void buildRequest(BWAPI::UnitType type); 00045 void buildRequest(BWAPI::UnitType type, bool checkUnic); 00046 void criticalBuildRequest(BWAPI::UnitType type); 00047 void criticalBuildRequest(BWAPI::UnitType type, bool first); 00048 void addonRequest(BWAPI::UnitType addonType); 00049 void researchRequest(BWAPI::TechType techType); 00050 void upgradeRequest(BWAPI::UpgradeType upgradeType); 00051 void upgradeRequest(BWAPI::UpgradeType upgradeType, int level); 00052 // Base 00053 enum Expand 00054 { 00055 Natural, 00056 Gas 00057 }; 00058 void naturalExpandRequest(bool critical = false); 00059 void gasExpandRequest(bool critical = false); 00060 void onCommandCenterShow(BWAPI::Unit* unit); 00061 void onEnemyResourceDepotShow(BWAPI::Unit* unit); 00062 void onCommandCenterDestroy(BWAPI::Unit* unit); 00063 void onEnemyResourceDepotDestroy(BWAPI::Unit* unit); 00064 BWAPI::TilePosition getNaturalExpandPosition(BWAPI::TilePosition ignorePosition = BWAPI::TilePositions::None); 00065 BWAPI::TilePosition getGasExpandPosition(BWAPI::TilePosition ignorePosition = BWAPI::TilePositions::None); 00066 00067 // enemy DPS map: 00068 double get_enemy_air_dps(BWAPI::TilePosition, int cycle); 00069 double get_enemy_ground_dps(BWAPI::TilePosition, int cycle); 00070 double get_enemy_air_dps(int x, int y, int cycle); 00071 double get_enemy_ground_dps(int x, int y, int cycle); 00072 void recompute_enemy_dps(int cycle); 00073 void drawAirDPSMap(); 00074 void drawGroundDPSMap(); 00075 00076 // Military information 00077 UnitSet _seenEnemies; 00078 UnitToTypeMap _enemiesType; 00079 unsigned int _minSquadSize; 00080 bool _needAntiAirUnits; 00081 bool _retreatDisabled; 00082 UnitToTimeMap _tankSiege; 00083 // Self army 00084 double _marines, _medics, _firebats, _ghosts; 00085 double _vultures, _tank, _goliath; 00086 double _wraiths; 00087 // Enemy Terran army 00088 double _enemyMarines, _enemyMedics, _enemyFirebats, _enemyGhosts; 00089 double _enemyVultures, _enemyTank, _enemyGoliath; 00090 double _enemyWraiths, _enemyDropship, _enemyScienceVessel, _enemyBattlecruiser, _enemyValkyrie; 00091 double _enemyTurrets; 00092 // Enemy Protoss army 00093 double _enemyZealot, _enemyDragoon, _enemyHTemplar, _enemyDTemplar, _enemyArchon, _enemyDArchon; 00094 double _enemyReaver, _enemyObserver, _enemyShuttle; 00095 double _enemyScout, _enemyCarrier, _enemyArbiter, _enemyCorsair; 00096 double _enemyPhotonCanon; 00097 // Enemy Zerg army 00098 double _enemyZergling, _enemyHydralisk, _enemyOverlord; 00099 double _enemyLurker, _enemyMutalisk; 00100 double _enemyUltralisk, _enemyGuardian, _enemyDevourer; 00101 double _enemySunkenColony, _enemySporeColony; 00102 // stats 00103 double _ourAirDPS, _ourAntiAirHP, _ourGroundDPS, _ourAirHP, _ourGroundHP; 00104 double _armySize; 00105 double _enemyAirDPS, _enemyAntiAirHP, _enemyGroundDPS, _enemyAirHP, _enemyGroundHP; 00106 double _enemyArmySize; 00107 00108 // Production information 00109 BuildingToUnitMap _trainOrder; 00110 std::vector<BWAPI::UnitType> _buildRequest; 00111 std::vector<BWAPI::UnitType> _criticalBuildRequest; 00112 BuildingToAddonMap _addonOrder; 00113 BuildingToTechMap _researchOrder; 00114 BuildingToUpgradeMap _upgradeOrder; 00115 UnitToPercent _percentList; 00116 void checkRequirements(BWAPI::UnitType type); 00117 bool _autoVehicleUpgrade; 00118 bool _autoShipUpgrade; 00119 bool _autoInfanteryUpgrade; 00120 00121 // Events information 00122 void seenCloakedEnemy(BWAPI::TilePosition pos); 00123 TilePositionSet _cloakedEnemyPositions; 00124 bool _turretDefenses; 00125 //bool _enemyWorkerScout; 00126 bool _scienceVesselDetector; 00127 00128 // Base and Buildings 00129 Expand _expandType; 00130 std::map<BWTA::BaseLocation*, BWAPI::TilePosition> _ourBases; 00131 std::map<BWTA::BaseLocation*, BWAPI::Unit*> _basesUnderConstruction; 00132 std::set<BWTA::BaseLocation*> _emptyBases; 00133 std::set<BWTA::BaseLocation*> _enemyBases; 00134 std::set<BWAPI::TilePosition> _ignoreBases; 00135 BWAPI::TilePosition _proxyPosition; 00136 bool _useProxyPosition; 00137 void onMissileTurretShow(BWAPI::Unit* unit); 00138 void onMissileTurretDestroy(BWAPI::Unit* unit); 00139 std::map<BWAPI::Unit*, BWTA::Region*> _missileTurrets; 00140 bool _autoBuildSuplies; 00141 bool _priorCommandCenters; 00142 00143 // Map information //TODO revise this information 00144 BWAPI::Position _enemyStartPosition; 00145 bool mapAnalyzed; 00146 BWTA::Region* home; 00147 std::set<BWTA::BaseLocation*> startLocationCouldContainEnemy; 00148 bool _scoutedAnEnemyBase; 00149 BWTA::Chokepoint* _choke; 00150 00151 // Debug variables 00152 BWAPI::Position _topLeft; 00153 BWAPI::Position _bottomRight; 00154 BWAPI::Position _center; 00155 int _radius; 00156 00157 // Enemy DPS map: (stores, for each cell of the map, the aggregated dps that the seen units of the enemy can do to our units in that cell) 00158 int _last_cycle_dps_map_was_recomputed; 00159 double *_ground_enemy_dps_map; 00160 double *_air_enemy_dps_map; 00161 00162 00163 // TODO move to scoutManager 00164 UnitToTimeMap _comsatStation; 00165 void scanBases(); 00166 bool useScanner(BWAPI::Unit* comsat, BWAPI::Position pos); 00167 std::set<BWTA::BaseLocation*>::iterator _lastBaseScan; 00168 std::set<BWAPI::TilePosition>::iterator _lastIgnoreBaseScan; 00169 };