BWAPI
|
00001 #pragma once 00002 /* 00003 * EnhancedChokepoint.h 00004 */ 00005 #include <BWAPI.h> 00006 #include <BWTA.h> 00007 00008 #include <EnhancedUI.h> 00009 #include <EnhancedSide.h> 00010 00011 #include <assert.h> 00012 00013 using std::pair; 00014 using std::vector; 00015 00016 class EnhancedChokepoint 00017 { 00018 public: 00019 EnhancedChokepoint(BWTA::Chokepoint * chokepoint); 00020 ~EnhancedChokepoint(void); 00021 /* BWTA Chokepoint functions */ 00022 const pair<BWTA::Region *, BWTA::Region *> & getRegions(); 00023 const pair<BWAPI::Position, BWAPI::Position> & getSides(); 00024 BWAPI::Position getCenter(); 00025 double getWidth(); 00026 00027 /* enhanced functionality */ 00028 bool isPositionInPolygon(BWAPI::Position searchPos, BWTA::Polygon poly); 00029 vector<EnhancedSide> & getBoundingBoxSidesForRegion(BWTA::Region * region); 00030 BWAPI::TilePosition getBuildTile(BWTA::Region * region); 00031 void drawTilePositions(void); 00032 void drawBoundingBox(void); 00033 void drawBoundingBoxSidesForRegion(BWTA::Region * region, BWAPI::Color color); 00034 void drawBuildableTilesForRegion(BWTA::Region * region, BWAPI::Color color); 00035 void drawBuildableSupplyDepotForRegion(BWTA::Region * region, BWAPI::Color color); 00036 00037 00038 private: 00039 BWTA::Chokepoint * cp; 00040 /* tiles for chokepoint line sides and center positions */ 00041 pair<BWAPI::TilePosition, BWAPI::TilePosition> tPosSides; 00042 BWAPI::TilePosition tPosCenter; 00043 /* bounding box coords */ 00044 int xLeft, xRight, yTop, yBottom; 00045 /* pair a region to sides of bounding box, there are only 2 regions per chokepoint */ 00046 pair<BWTA::Region * , vector<EnhancedSide>> regionASides; 00047 pair<BWTA::Region * , vector<EnhancedSide>> regionBSides; 00048 // tiles near the chokepoint region side that are buildable 00049 // goes only as far to find first buildable supply depot 00050 pair<BWTA::Region * , vector<BWAPI::TilePosition>> regionABuildableTiles; 00051 pair<BWTA::Region * , vector<BWAPI::TilePosition>> regionBBuildableTiles; 00052 // tile near the chokepoint region that can be used to build 00053 // a supply depot 00054 pair<BWTA::Region * , BWAPI::TilePosition> regionABuildTile; 00055 pair<BWTA::Region * , BWAPI::TilePosition> regionBBuildTile; 00056 00057 bool isSideInRegion(pair<BWAPI::Position, BWAPI::Position> endPoints, BWTA::Region * region); 00058 // used to find buildable tiles and a build tile for a supply depot 00059 void radialSweepSearch(pair<BWTA::Region * , vector<EnhancedSide>> regionSides); 00060 };