-
Notifications
You must be signed in to change notification settings - Fork 178
Design and Architecture
David Churchill edited this page Mar 6, 2020
·
8 revisions
Here is the complete sequential logic flow of UAlbertaBot:
-
UAlbertaBot.onFrame()
-
GameCommander.update()
-
WorkerManager.update()
- Re-allocate workers to new mineral patches if mined out
- Send idle workers to gather minerals
- Allocate gas workers until 3 in each refinery
- Move build workers to building location if necessary
-
ProductionManager.update()
- If event occurs which triggers a new build order
- Clear current build order
- Get new build order goal from
StrategyManager
- Set new build order from
StarcraftBuildOrderSearch
- If current build order contains items
- If the highest priority item can be built
- Build the highest priority item
- If the highest priority item can be built
- If event occurs which triggers a new build order
-
BuildingManager.update()
- Check to see if assigned workers have died en route or while constructing
- Assign workers to the unassigned buildings and label them planned
- For each planned building, if the worker isn't constructing, send the command
- Update status of buildings which have started construction
- If we are terran and a building is under construction without a worker, assign a new one
- Check if any buildings have completed and update data structures
-
CombatCommander.update()
- Set a worker to scout if it is the appropriate time
- If any of our occupied regions contain enemy units, create defense Squad to defend
- If additional combat units are available, attack as follows:
- If we know of a visible enemy base location, attack it
- Otherwise, if we see visible units, attack them
- Otherwise, if we know where an enemy building was, attack it
- Otherwise, explore until we find a new attack target
-
Squads.update()
- perform squad commands- Perform
CombatSimulation
- If simulation returns victory
- Continue attacking toward current target
- Call associated
MicroManager
sub-class for each unit type
- If simulation returns defeat
- Retreat Squad toward own base
- If simulation returns victory
- Perform
-
ScoutManager.update()
- If we know where enemy base is
- If we are outside enemy base, go toward it
- If we are inside enemy base, attack closest worker
- If enemy worker attacks back, retreat
- If we don't know where enemy base is
- Visit base location least recently visited until found
- If we know where enemy base is
-
InformationManager.update()
- For each enemy unit we can see, update its last known position and unit details
- For each enemy building we see, update it as a known enemy base location
- If we see enemy detectors, make note
- If we see enemy cloaked units, make note
-
MapGrid.update()
- For each occupied grid space, update its time last visited
-
MapTools.update()
- N/A -
MapTools
is only polled for path finding details
- N/A -
-
BOSSManager.update()
- If a goal is given, perform search for a given time limit
-
-
UAlbertaBot was designed to have an intuitive hierarchical structure based on proven military command systems. This structure is beneficial for several reasons:
- Intuitive classes for ease of interpretation
- ex:
ProductionManager
handles every task related to production of buildingd and units
- ex:
- Modular design allows for easy modifications and updates over time
- ex: To change unit micro behaviour simply replace the
MicroManager
sub-classes
- ex: To change unit micro behaviour simply replace the
- Vertical communication reduces code complexity
- ex: Only
CombatCommander
can talk toSquad
, passing it orders
- ex: Only
- Information is on a need-to-know basis, reducing data transfer between modules
- ex: Only
WorkerManager
knows which workers are assigned to which jobs
- ex: Only
- Vertical structure avoids code duplication
There are a few cases of global communication in UAlberaBot, which are implemented via globally accessible Singleton
classes. These classes contain information that would be desired in multiple parts of the bot, such as information about production, workers, strategy, or map details. To make them easy to access, they are all accessible via the Global
class, found in Global.h. If you ever forget the name of a Global class, just type Global::
in visual studio, and Auto Complete will list them all.
These classes are:
-
InformationManager
-Global::Info()
- Computes and stores important information about units which each other manager may want access to (ie: determine if opponent has a detector)
-
MapTools
-Global::Map()
- Performs ground-distance path finding and caches results for later retrieval
-
StrategyManager
-Global::Strategy()
- Makes decisions about build-order goals, when to expand, and other game policies
-
BaseLocationManager
-Global::Bases()
- Computes the location of Bases on the map, and updates their occupancy
-
ScoutManager
-Global::Scout
- Performs all logic related to scouting the map