BWAPI
|
00001 #pragma once 00002 00003 #include "Interface.h" 00004 00005 #include "TypeSafeEnum.h" 00006 #include "Unit.h" 00007 #include "Base.h" 00008 00009 struct ReservationTypeDef 00010 { 00011 enum type 00012 { 00013 LandingPosition, 00014 BuildingPosition 00015 }; 00016 }; 00017 typedef SafeEnum<ReservationTypeDef> ReservationType; 00018 00019 struct BuildingLocationDef 00020 { 00021 enum type 00022 { 00023 None, 00024 Base, //best base choice, usually main 00025 BaseParimeter, //place evenly around main base, for turrets etc 00026 BaseChoke, //place at the main bases choke, for bunkers etc 00027 ForwardChoke, //place at a forward choke position, such as an expansion if there is one 00028 ForwardParimeter, //place evenly around all buildings, for turrets etc 00029 Expansion, //best expansion location 00030 ExpansionGas, //best expansion location, only chooses a gas only 00031 Proxy, //proxy location, places it closest to possible enemy base locations that arn't on paths between the bases 00032 Manner //place in enemy base, if pylon block enemy units, if gas, steal gas if possible 00033 }; 00034 }; 00035 typedef SafeEnum<BuildingLocationDef> BuildingLocation; 00036 00037 class ReservedLocationClass : public std::tr1::enable_shared_from_this<ReservedLocationClass> 00038 { 00039 public: 00040 ReservedLocationClass(BWAPI::UnitType type, BuildingLocation location); 00041 ReservedLocationClass(Unit unit); 00042 00043 TilePosition getTilePosition() { return mTilePosition; } 00044 Position getPosition() { return mPosition; } 00045 00046 Base getBase() { return mBase; } 00047 00048 BWAPI::UnitType getUnitType() { return mUnitType; } 00049 00050 bool update(); 00051 00052 BuildingLocation getBuildLocation() { return mLocation; } 00053 Unit getUnitPrediction() { return mUnitPrediction; } 00054 00055 bool isCalculated() { return mTilePosition != BWAPI::TilePositions::None; } 00056 00057 void setStartTime(int time); 00058 00059 void forceCompleted() { mForcedCompleted = true; } 00060 00061 private: 00062 bool shouldFree(); 00063 void setTilePosition(TilePosition position); 00064 00065 ReservationType mType; 00066 BWAPI::UnitType mUnitType; 00067 00068 BuildingLocation mLocation; 00069 00070 Base mBase; 00071 TilePosition mTilePosition; 00072 Position mPosition; 00073 00074 Unit mUnit; 00075 00076 int mNextCalculationAttempt; 00077 00078 int mStartTime; 00079 00080 Unit mUnitPrediction; 00081 00082 bool mForcedCompleted; 00083 }; 00084 00085 typedef std::tr1::shared_ptr<ReservedLocationClass> ReservedLocation;