|
BWAPIOverview
Class DiagramHere is the class diagram of BWAPI: class diagram. Not all functions are shown for each class, and some classes are not included in the diagram (like Position). Creating an AIYou can either create an AI as an AI Module DLL that gets loaded into Starcraft at the start of a match, or as a stand-alone client process that communicates with BWAPI via shared memory. An example of each of these is included in each release of BWAPI. Main ClassesThe 5 main BWAPI classes that get information from Starcraft are Game, Force, Player, Unit, and Bullet. Game is your primary interface to BWAPI. Using this class you can get sets of forces, players, units, and bullets. You can also issue commands to the game to pause the game, move the screen, and do other things. Force usually not very useful except in certain game modes. Sometimes forces correspond to teams, but not always. This is the least used class that interacts with Broodwar. Player can be used to get information about each player in the current match. Unit can be used to get information about and control individual units. Bullet can be used to get information about individual bullet objects. Not all attack animations generate bullet objects. Cheat flagsThere are two cheat flags, each of which are disabled by default:
The four tiers of unit accessibilityEach unit in the game will be at one of the following levels of accessibility, depending on a number of factors. 1) Full AccessibilityAll of units owned by the BWAPI player/AI are fully accessible all of the time while they are alive. If the Complete Map Information flag is enabled, or if the match is a replay, then all of the units in the match will be fully accessible, not just the units owned by self(). If the Complete Map Information flag is disabled and the match is not a replay, then neutral and enemy units will fall into one of the remaining tiers of accessibility. Frame 0 notes:
2) Normal AccessibilityWhen complete map information is disabled, then all visible and detected enemy units will have normal accessibility. This includes all of the attributes in full accessibility EXCEPT for the following:
These inaccessible functions will just return 0/NULL/false/etc, depending on the return type. 3) Partial AccessibilityUnits that return true for Unit::isVisible but false for Unit::isDetected are partially accessible. Cloaked enemy that are not covered by fog of war will return true for Unit::isVisible, and thus always be at least partially visible. Burrowed enemy units that are not covered by fog of war will return true for Unit::isVisible only if they are attacking or detected (by a Science Vessel or other detection unit). Partial accessibility includes access to the following functions:
The initial value functions are also still accessible at this level, however I don't think its possible for neutral units (like mineral patches) to cloak, so I don't think they would be of any use here. Note: AIModule::onUnitShow and AIModule::onUnitHide occur when the unit switches between partial accessibility and no accessibility. If Complete Map Info is disabled, then AIModule::onUnitDiscover and AIModule::onUnitEvade also occur during this transition. 4) No AccessibilityUnits that are dead will have no accessibility. If Complete Map Info is disabled, then units shrouded by Fog of War will also have no accessibility, even if they are still alive. The initial value functions, however, are always accessible at all levels: These only apply for neutral units that existed at the start of the match are are useful for getting general/static knowledge of the map even when complete map info is disabled. To obtain this static map info use these functions on the units returned by: | |