BWAPI
SnippyHolloW-BroodwarBotQ-f01ab56/src/Intelligence/enums_name_tables_tt.h
Go to the documentation of this file.
00001 #ifndef ENUMS_NAME_TABLES
00002 #define ENUMS_NAME_TABLES
00003 
00004 #include <string>
00005 #include <iostream>
00006 #include <BWAPI.h>
00007 
00010 
00011 #define TERRAN_X_UNITS \
00012     X(Terran_Marine, (const char*) "Terran_Marine") \
00013     X(Terran_Ghost,  (const char*) "Terran_Ghost") \
00014     X(Terran_Vulture,  (const char*) "Terran_Vulture") \
00015     X(Terran_Goliath,  (const char*) "Terran_Goliath") \
00016     X(Terran_Siege,  (const char*) "Terran_Siege_Tank") \
00017     X(Terran_SCV,  (const char*) "Terran_SCV") \
00018     X(Terran_Wraith,  (const char*) "Terran_Wraith") \
00019     X(Terran_Science_Vessel,  (const char*) "Terran_Science_Vessel") \
00020     X(Terran_Dropship,  (const char*) "Terran_Dropship") \
00021     X(Terran_Battlecruiser,  (const char*) "Terran_Battlecruiser") \
00022     X(Terran_Vulture_Spider_Mine,  (const char*) "Terran_Vulture_Spider_Mine") \
00023     X(Terran_Nuclear_Missile,  (const char*) "Terran_Nuclear_Missile") \
00024     X(Terran_Siege_Tank_Siege_Mode,  (const char*) "Terran_Siege_Tank_Siege_Mode") \
00025     X(Terran_Firebat,  (const char*) "Terran_Firebat") \
00026     X(Terran_Medic,  (const char*) "Terran_Medic") \
00027     X(Terran_Valkyrie,  (const char*) "Terran_Valkyrie")
00028 
00029 #define X(a, b) a,
00030 enum Terran_Units
00031 {
00032     TERRAN_X_UNITS
00033 };
00034 #undef X
00035 
00036 #define X(a, b) b,
00037 const char* terran_units_name[] = 
00038 {
00039     TERRAN_X_UNITS
00040 };
00041 #undef X
00042 
00043 #define NB_TERRAN_UNITS 16
00044 
00045 #define TERRAN_X_BUILDINGS \
00046     X(Terran_Command_Center, (const char*) "Terran_Command_Center") \
00047     X(Terran_Command_Center2, (const char*) "Terran_Command_Center2") \
00048     X(Terran_Command_Center3, (const char*) "Terran_Command_Center3") \
00049     X(Terran_ComSat, (const char*) "Terran_ComSat") \
00050     X(Terran_Nuclear_Silo, (const char*) "Terran_Nuclear_Silo") \
00051     X(Terran_Supply_Depot, (const char*) "Terran_Supply_Depot") \
00052     X(Terran_Supply_Depot2, (const char*) "Terran_Supply_Depot2") \
00053     X(Terran_Supply_Depot3, (const char*) "Terran_Supply_Depot3") \
00054     X(Terran_Refinery, (const char*) "Terran_Refinery") \
00055     X(Terran_Refinery2, (const char*) "Terran_Refinery2") \
00056     X(Terran_Barracks, (const char*) "Terran_Barracks") \
00057     X(Terran_Barracks2, (const char*) "Terran_Barracks2") \
00058     X(Terran_Barracks3, (const char*) "Terran_Barracks3") \
00059     X(Terran_Barracks4, (const char*) "Terran_Barracks4") \
00060     X(Terran_Academy, (const char*) "Terran_Academy") \
00061     X(Terran_Factory, (const char*) "Terran_Factory") \
00062     X(Terran_Starport, (const char*) "Terran_Starport") \
00063     X(Terran_Control_Tower, (const char*) "Terran_Control_Tower") \
00064     X(Terran_Science_Facility, (const char*) "Terran_Science_Facility") \
00065     X(Terran_Covert_Ops, (const char*) "Terran_Covert_Ops") \
00066     X(Terran_Physics_Lab, (const char*) "Terran_Physics_Lab") \
00067     X(Terran_Machine_Shop, (const char*) "Terran_Machine_Shop") \
00068     X(Terran_Engineering_Bay, (const char*) "Terran_Engineering_Bay") \
00069     X(Terran_Armory, (const char*) "Terran_Armory") \
00070     X(Terran_Missile_Turret, (const char*) "Terran_Missile_Turret") \
00071     X(Terran_Bunker, (const char*) "Terran_Bunker")
00072 
00073 #define X(a, b) a,
00074 enum Terran_Buildings
00075 {
00076     TERRAN_X_BUILDINGS
00077 };
00078 #undef X
00079 
00080 #define X(a, b) b,
00081 const char* terran_buildings_name[] = 
00082 {
00083     TERRAN_X_BUILDINGS
00084 };
00085 #undef X
00086 
00087 #define NB_TERRAN_BUILDINGS 26
00088 
00089 #define PROTOSS_X_UNITS \
00090     X(Protoss_Corsair, (const char*) "Protoss_Corsair") \
00091     X(Protoss_Dark_Templar, (const char*) "Protoss_Dark_Templar") \
00092     X(Protoss_Dark_Archon, (const char*) "Protoss_Dark_Archon") \
00093     X(Protoss_Probe, (const char*) "Protoss_Probe") \
00094     X(Protoss_Zealot, (const char*) "Protoss_Zealot") \
00095     X(Protoss_Dragoon, (const char*) "Protoss_Dragoon") \
00096     X(Protoss_High_Templar, (const char*) "Protoss_High_Templar") \
00097     X(Protoss_Archon, (const char*) "Protoss_Archon") \
00098     X(Protoss_Shuttle, (const char*) "Protoss_Shuttle") \
00099     X(Protoss_Scout, (const char*) "Protoss_Scout") \
00100     X(Protoss_Arbiter, (const char*) "Protoss_Arbiter") \
00101     X(Protoss_Carrier, (const char*) "Protoss_Carrier") \
00102     X(Protoss_Interceptor, (const char*) "Protoss_Interceptor") \
00103     X(Protoss_Reaver, (const char*) "Protoss_Reaver") \
00104     X(Protoss_Observer, (const char*) "Protoss_Observer") \
00105     X(Protoss_Scarab, (const char*) "Protoss_Scarab")
00106 
00107 #define X(a, b) a,
00108 enum Protoss_Units
00109 {
00110     PROTOSS_X_UNITS
00111 };
00112 #undef X
00113 
00114 #define X(a, b) b,
00115 const char* protoss_units_name[] =
00116 {
00117     PROTOSS_X_UNITS
00118 };
00119 #undef X
00120 
00121 #define NB_PROTOSS_UNITS 16
00122 
00123 #define PROTOSS_X_BUILDINGS \
00124     X(Protoss_Nexus, (const char*) "Protoss_Nexus") \
00125     X(Protoss_Nexus2, (const char*) "Protoss_Nexus2") \
00126     X(Protoss_Nexus3, (const char*) "Protoss_Nexus3") \
00127     X(Protoss_Robotics_Facility, (const char*) "Protoss_Robotics_Facility") \
00128     X(Protoss_Pylon, (const char*) "Protoss_Pylon") \
00129     X(Protoss_Pylon2, (const char*) "Protoss_Pylon2") \
00130     X(Protoss_Pylon3, (const char*) "Protoss_Pylon3") \
00131     X(Protoss_Assimilator, (const char*) "Protoss_Assimilator") \
00132     X(Protoss_Assimilator2, (const char*) "Protoss_Assimilator2") \
00133     X(Protoss_Observatory, (const char*) "Protoss_Observatory") \
00134     X(Protoss_Gateway, (const char*) "Protoss_Gateway") \
00135     X(Protoss_Gateway2, (const char*) "Protoss_Gateway2") \
00136     X(Protoss_Gateway3, (const char*) "Protoss_Gateway3") \
00137     X(Protoss_Gateway4, (const char*) "Protoss_Gateway4") \
00138     X(Protoss_Photon_Cannon, (const char*) "Protoss_Photon_Cannon") \
00139     X(Protoss_Citadel_of_Adun, (const char*) "Protoss_Citadel_of_Adun") \
00140     X(Protoss_Cybernetics_Core, (const char*) "Protoss_Cybernetics_Core") \
00141     X(Protoss_Templar_Archives, (const char*) "Protoss_Templar_Archives") \
00142     X(Protoss_Forge, (const char*) "Protoss_Forge") \
00143     X(Protoss_Stargate, (const char*) "Protoss_Stargate") \
00144     X(Protoss_Fleet_Beacon, (const char*) "Protoss_Fleet_Beacon") \
00145     X(Protoss_Arbiter_Tribunal, (const char*) "Protoss_Arbiter_Tribunal") \
00146     X(Protoss_Robotics_Support_Bay, (const char*) "Protoss_Robotics_Support_Bay") \
00147     X(Protoss_Shield_Battery, (const char*) "Protoss_Shield_Battery")
00148 
00149 #define X(a, b) a,
00150 enum Protoss_Buildings
00151 {
00152     PROTOSS_X_BUILDINGS
00153 };
00154 #undef X
00155 
00156 #define X(a, b) b,
00157 const char* protoss_buildings_name[] =
00158 {
00159     PROTOSS_X_BUILDINGS
00160 };
00161 #undef X
00162 
00163 #define NB_PROTOSS_BUILDINGS 24
00164 
00165 #define ZERG_X_UNITS \
00166     X(Zerg_Larva, (const char*) "Zerg_Larva") \
00167     X(Zerg_Egg, (const char*) "Zerg_Egg") \
00168     X(Zerg_Zergling, (const char*) "Zerg_Zergling") \
00169     X(Zerg_Hydralisk, (const char*) "Zerg_Hydralisk") \
00170     X(Zerg_Ultralisk, (const char*) "Zerg_Ultralisk") \
00171     X(Zerg_Broodling, (const char*) "Zerg_Broodling") \
00172     X(Zerg_Drone, (const char*) "Zerg_Drone") \
00173     X(Zerg_Mutalisk, (const char*) "Zerg_Mutalisk") \
00174     X(Zerg_Guardian, (const char*) "Zerg_Guardian") \
00175     X(Zerg_Queen, (const char*) "Zerg_Queen") \
00176     X(Zerg_Defiler, (const char*) "Zerg_Defiler") \
00177     X(Zerg_Scourge, (const char*) "Zerg_Scourge") \
00178     X(Zerg_Infested_Terran, (const char*) "Zerg_Infested_Terran") \
00179     X(Zerg_Cocoon, (const char*) "Zerg_Cocoon") \
00180     X(Zerg_Devourer, (const char*) "Zerg_Devourer") \
00181     X(Zerg_Lurker_Egg, (const char*) "Zerg_Lurker_Egg") \
00182     X(Zerg_Lurker, (const char*) "Zerg_Lurker")
00183 
00184 #define X(a, b) a,
00185 enum Zerg_Units
00186 {
00187     ZERG_X_UNITS
00188 };
00189 #undef X
00190 
00191 #define X(a, b) b,
00192 const char* zerg_units_name[] =
00193 {
00194     ZERG_X_UNITS
00195 };
00196 #undef X
00197 
00198 #define NB_ZERG_UNITS 17
00199 
00200 #define ZERG_X_BUILDINGS \
00201     X(Zerg_Hatchery, (const char*) "Zerg_Hatchery") \
00202     X(Zerg_Hatchery2, (const char*) "Zerg_Hatchery2") \
00203     X(Zerg_Hatchery3, (const char*) "Zerg_Hatchery3") \
00204     X(Zerg_Hatchery4, (const char*) "Zerg_Hatchery4") \
00205     X(Zerg_Lair, (const char*) "Zerg_Lair") \
00206     X(Zerg_Hive, (const char*) "Zerg_Hive") \
00207     X(Zerg_Nydus_Canal, (const char*) "Zerg_Nydus_Canal") \
00208     X(Zerg_Hydralisk_Den, (const char*) "Zerg_Hydralisk_Den") \
00209     X(Zerg_Defiler_Mound, (const char*) "Zerg_Defiler_Mound") \
00210     X(Zerg_Greater_Spire, (const char*) "Zerg_Greater_Spire") \
00211     X(Zerg_Queens_Nest, (const char*) "Zerg_Queens_Nest") \
00212     X(Zerg_Evolution_Chamber, (const char*) "Zerg_Evolution_Chamber") \
00213     X(Zerg_Ultralisk_Cavern, (const char*) "Zerg_Ultralisk_Cavern") \
00214     X(Zerg_Spire, (const char*) "Zerg_Spire") \
00215     X(Zerg_Spawning_Pool, (const char*) "Zerg_Spawning_Pool") \
00216     X(Zerg_Creep_Colony, (const char*) "Zerg_Creep_Colony") \
00217     X(Zerg_Spore_Colony, (const char*) "Zerg_Spore_Colony") \
00218     X(Zerg_Sunken_Colony, (const char*) "Zerg_Sunken_Colony") \
00219     X(Zerg_Extractor, (const char*) "Zerg_Extractor")\
00220     X(Zerg_Extractor2, (const char*) "Zerg_Extractor2")\
00221     \
00222     X(Zerg_Overlord, (const char*) "Zerg_Overlord") \
00223     X(Zerg_Overlord2, (const char*) "Zerg_Overlord2") \
00224     X(Zerg_Overlord3, (const char*) "Zerg_Overlord3") \
00225 
00226 #define X(a, b) a,
00227 enum Zerg_Buildings
00228 {
00229     ZERG_X_BUILDINGS
00230 };
00231 #undef X
00232 
00233 #define X(a, b) b,
00234 const char* zerg_buildings_name[] =
00235 {
00236     ZERG_X_BUILDINGS
00237 };
00238 #undef X
00239 
00240 #define NB_ZERG_BUILDINGS 24
00241 
00242 enum Spells
00243 {
00244     Spell_Scanner_Sweep,
00245     Spell_Disruption_Web,
00246     Spell_Dark_Swarm
00247 };
00248 
00249 class Building
00250 {
00251     friend std::ostream& operator <<(std::ostream& os, const Building& b);
00252     int _enumValue;
00253     int _tableSize;
00254     const char** _nameTable;
00255 public:
00256     Building(Protoss_Buildings v)
00257         : _enumValue(v)
00258         , _nameTable(protoss_buildings_name)
00259         , _tableSize(NB_PROTOSS_BUILDINGS)
00260     {
00261     }
00262     Building(Terran_Buildings v)
00263         : _enumValue(v)
00264         , _nameTable(terran_buildings_name)
00265         , _tableSize(NB_TERRAN_BUILDINGS)
00266     {
00267     }
00268     Building(Zerg_Buildings v)
00269         : _enumValue(v)
00270         , _nameTable(zerg_buildings_name)
00271         , _tableSize(NB_ZERG_BUILDINGS)
00272     {
00273     }
00274     Building(const char* buildingName)
00275     {
00276         if (buildingName[0] == 'P')
00277         {
00278             _tableSize = NB_PROTOSS_BUILDINGS;
00279             _nameTable = protoss_buildings_name;
00280         } 
00281         else if (buildingName[0] == 'T')
00282         {
00283             _tableSize = NB_TERRAN_BUILDINGS;
00284             _nameTable = terran_buildings_name;
00285         } 
00286         else if (buildingName[0] == 'Z')
00287         {
00288             _tableSize = NB_ZERG_BUILDINGS;
00289             _nameTable = zerg_buildings_name;
00290         } 
00291         else
00292         {
00293                         BWAPI::Broodwar->printf("ERROR: Building constructor failed to determine the race -> %s", buildingName);
00294         }
00295         for (int i = 0; i < _tableSize; i++)
00296         {
00297             if (!strcmp(buildingName, _nameTable[i]))
00298             {
00299                 _enumValue = i;
00300                 return;
00301             }
00302         }
00303                 BWAPI::Broodwar->printf("ERROR: not found this building: %s", buildingName);
00304     }
00305     std::ostream& operator <<(std::ostream& os) const
00306     {
00307         if (_enumValue < _tableSize)
00308             os << std::string(_nameTable[_enumValue]);
00309         else
00310             os << "ERROR: _enumValue too big: " << _enumValue;
00311         return os;
00312     }
00313     int getEnumValue() const
00314     {
00315         return _enumValue;
00316     }
00317         const char** getName() const
00318         {
00319                 return _nameTable;
00320         }
00321 };
00322 inline std::ostream& operator <<(std::ostream& os, const Building& b)
00323 {
00324     if (b._enumValue < b._tableSize)
00325         os << std::string(b._nameTable[b._enumValue]);
00326     else
00327         os << "ERROR: _enumValue too big: " << b._enumValue;
00328     return os;
00329 }
00330 
00331 struct tree_node
00332 {
00333     int value;
00334     std::map<int, tree_node*> children;
00335     void append(int v)
00336     {
00337         children.insert(std::make_pair<int, tree_node*>(v, new tree_node(v)));
00338     }
00339     void append(tree_node* tn)
00340     {
00341         children.insert(std::make_pair<int, tree_node*>(tn->value, tn));
00342     }
00343     tree_node(int v): value(v) {}
00344     tree_node(const char* p) : value(Protoss_Nexus) // root
00345     {
00346         if (p[0] == 'P')
00347         {
00348             this->append(Protoss_Nexus);
00349             this->append(Protoss_Nexus2);
00350             this->append(Protoss_Nexus3);
00351             this->append(Protoss_Pylon);
00352             this->append(Protoss_Pylon2);
00353             this->append(Protoss_Pylon3);
00354             this->append(Protoss_Assimilator);
00355             this->append(Protoss_Assimilator2);
00356             this->append(Protoss_Gateway);
00357             this->append(Protoss_Gateway2);
00358             this->append(Protoss_Gateway3);
00359             this->append(Protoss_Gateway4);
00360             this->append(Protoss_Forge);
00361             children[Protoss_Forge]->append(Protoss_Photon_Cannon);
00362             children[Protoss_Gateway]->append(Protoss_Shield_Battery);
00363             children[Protoss_Gateway]->append(Protoss_Cybernetics_Core);
00364             children[Protoss_Gateway]->children[Protoss_Cybernetics_Core]->
00365                 append(Protoss_Stargate);
00366             children[Protoss_Gateway]->children[Protoss_Cybernetics_Core]->
00367                 append(Protoss_Citadel_of_Adun);
00368             children[Protoss_Gateway]->children[Protoss_Cybernetics_Core]->
00369                 append(Protoss_Robotics_Facility);
00370             children[Protoss_Gateway]->children[Protoss_Cybernetics_Core]->
00371                 children[Protoss_Robotics_Facility]->
00372                 append(Protoss_Robotics_Support_Bay);
00373             children[Protoss_Gateway]->children[Protoss_Cybernetics_Core]->
00374                 children[Protoss_Robotics_Facility]->append(Protoss_Observatory);
00375             children[Protoss_Gateway]->children[Protoss_Cybernetics_Core]->
00376                 children[Protoss_Citadel_of_Adun]->
00377                 append(Protoss_Templar_Archives);
00378             children[Protoss_Gateway]->children[Protoss_Cybernetics_Core]->
00379                 children[Protoss_Stargate]->append(Protoss_Fleet_Beacon);
00380             tree_node* tribunal = new tree_node(Protoss_Arbiter_Tribunal);
00381             children[Protoss_Gateway]->children[Protoss_Cybernetics_Core]->
00382                 children[Protoss_Citadel_of_Adun]->
00383                 children[Protoss_Templar_Archives]->append(tribunal);
00384             children[Protoss_Gateway]->children[Protoss_Cybernetics_Core]->
00385                 children[Protoss_Stargate]->append(tribunal);
00386         }
00387         else if (p[0] == 'T')
00388         {
00389             this->append(Terran_Command_Center);
00390             this->append(Terran_Command_Center2);
00391             this->append(Terran_Command_Center3);
00392             this->append(Terran_ComSat);
00393             this->append(Terran_Nuclear_Silo);
00394             this->append(Terran_Supply_Depot);
00395             this->append(Terran_Supply_Depot2);
00396             this->append(Terran_Supply_Depot3);
00397             this->append(Terran_Refinery);
00398             this->append(Terran_Refinery2);
00399             this->append(Terran_Barracks);
00400             this->append(Terran_Barracks2);
00401             this->append(Terran_Barracks3);
00402             this->append(Terran_Barracks4);
00403             this->append(Terran_Engineering_Bay);
00404             children[Terran_Engineering_Bay]->append(Terran_Missile_Turret);
00405             children[Terran_Barracks]->append(Terran_Academy);
00406             children[Terran_Barracks]->append(Terran_Factory);
00407             children[Terran_Barracks]->append(Terran_Bunker);
00408             children[Terran_Barracks]->children[Terran_Factory]->
00409                 append(Terran_Starport);
00410             children[Terran_Barracks]->children[Terran_Factory]->
00411                 append(Terran_Armory);
00412             children[Terran_Barracks]->children[Terran_Factory]->
00413                 append(Terran_Machine_Shop);
00414             children[Terran_Barracks]->children[Terran_Factory]->
00415                 children[Terran_Starport]->append(Terran_Control_Tower);
00416             children[Terran_Barracks]->children[Terran_Factory]->
00417                 children[Terran_Starport]->append(Terran_Science_Facility);
00418             children[Terran_Barracks]->children[Terran_Factory]->
00419             children[Terran_Starport]->children[Terran_Science_Facility]->
00420                 append(Terran_Covert_Ops);
00421             children[Terran_Barracks]->children[Terran_Factory]->
00422             children[Terran_Starport]->children[Terran_Science_Facility]->
00423                 append(Terran_Physics_Lab);
00424         }
00425         else if (p[0] == 'Z')
00426         {
00427             this->append(Zerg_Hatchery);
00428             this->append(Zerg_Hatchery2);
00429             this->append(Zerg_Hatchery3);
00430             this->append(Zerg_Hatchery4);
00431             this->append(Zerg_Evolution_Chamber);
00432             this->append(Zerg_Spawning_Pool);
00433             this->append(Zerg_Creep_Colony);
00434             this->append(Zerg_Extractor);
00435             this->append(Zerg_Extractor2);
00436             this->append(Zerg_Overlord);
00437             this->append(Zerg_Overlord2);
00438             this->append(Zerg_Overlord3);
00439             children[Zerg_Evolution_Chamber]->append(Zerg_Spore_Colony);
00440             children[Zerg_Spawning_Pool]->append(Zerg_Sunken_Colony);
00441             children[Zerg_Spawning_Pool]->append(Zerg_Hydralisk_Den);
00442             children[Zerg_Hatchery]->append(Zerg_Lair);
00443             children[Zerg_Spawning_Pool]->append(children[Zerg_Hatchery]->
00444                     children[Zerg_Lair]);
00445             children[Zerg_Hatchery]->children[Zerg_Lair]->
00446                 append(Zerg_Spire);
00447             children[Zerg_Hatchery]->children[Zerg_Lair]->
00448                 append(Zerg_Queens_Nest);
00449             children[Zerg_Hatchery]->children[Zerg_Lair]->append(Zerg_Hive);
00450             children[Zerg_Hatchery]->children[Zerg_Lair]->
00451                 children[Zerg_Queens_Nest]->append(children[Zerg_Hatchery]->
00452                         children[Zerg_Lair]->children[Zerg_Hive]);
00453             children[Zerg_Hatchery]->children[Zerg_Lair]->children[Zerg_Hive]
00454                 ->append(Zerg_Nydus_Canal);
00455             children[Zerg_Hatchery]->children[Zerg_Lair]->children[Zerg_Hive]
00456                 ->append(Zerg_Defiler_Mound);
00457             tree_node* gspire = new tree_node(Zerg_Greater_Spire);
00458             children[Zerg_Hatchery]->children[Zerg_Lair]->children[Zerg_Hive]
00459                 ->append(gspire);
00460             children[Zerg_Hatchery]->children[Zerg_Lair]->children[Zerg_Spire]
00461                 ->append(gspire);
00462             children[Zerg_Hatchery]->children[Zerg_Lair]->children[Zerg_Hive]
00463                 ->append(Zerg_Ultralisk_Cavern);
00464         }
00465     }
00466     ~tree_node()
00467     {
00468         for (std::map<int, tree_node*>::iterator it = children.begin();
00469                 it != children.end(); ++it)
00470         {
00471             if (it->second != NULL)
00472                 delete it->second;
00473         }
00474     }
00475 };
00476 
00477 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines