A small starter guide to the code. “So you want to make a bot....”
First look at the configuration file documentation. Steamhammer’s opening build orders and some details of its play are in there, plus debug options and more. You will definitely want to make some changes—start with configuring your bot’s name. If you want to change the name of the config file, it is in Steamhammer/Source/Config.cpp
. I recommend that; it’s easier to keep track.
If you only change the config file, you haven’t made your own bot yet. A serious Starcraft bot takes a lot of coding (probably why many bots are not so serious). If you keep at it, you’ll get used to reading and changing the code, and you’ll learn the correct curse words for every bug. Here are the most important bits, so you can start to incubate your nefarious plot.
At the top level, the project has 2 parts.
StrategyManager
for terran and protoss; not used for zerg.Here are some of the important classes in the Steamhammer source. The entry point is UAlbertaBotModule
, which sets things up and then passes control for each game event to GameCommander
. Then GameCommander
calls on the various other modules to do the work.
Bases
- Keeps track of base locations: Where they are, who owns each one, and so on.BuildingManager
- Keeps a queue of buildings to construct, and constructs them, solving any problems (“oops, that spot turned out to be blocked”). Takes its orders from ProductionManager
.CombatCommander
- In charge of squads and overall tactics. Passes orders to Squad
objects.FAP
- FastAPproximation
combat simulator, to estimate whether a potential battle will be won or lost. Written by N00byEdge and included under its own MIT license. Modified by me to support dark swarm and ensnare.Grid
- Parent of subclasses that keep track of various information at the tile level (32x32 pixels) or walk tile level (8x8).InformationManager
- Keeps track of units (especially enemy units that have been seen).MacroAct
- The representation of a macro action, which may be a unit to build, research to conduct, an action to take, etc. Build orders are defined as lists of macro acts, and the strategy manager communicates its plans to the production manager in the form of macro acts.MapGrid
- Keeps track of the locations of units by grid square, for lookup by location. Also remembers when each part of the map is explored.MapPartitions
- Calculates which parts of the map are walkable (taking into account neutral buildings) and which are connected by ground.Micro
- Sends commands to units, being careful not to spam commands. MicroState
keeps track of what each unit is doing.MicroManager
- Parent class for making unit-level decisions during play, like what target to attack. Child classes are MicroMelee
, MicroRanged
, MicroTransports
, etc.OpponentModel
finds out and tracks information about each game, such as what kind of opening the opponent played. It saves game records for each opponent so the bot can adapt its play to the opponent’s habits.ParseUtils
- Reads the configuration file and sets configuration variables to match. If you want to add a new configuration variable, declare it in Config.h
and give it a default value in Config.cpp
, then parse its configured value and set the variable in ParseUtils
and you are done.ProductionManager
- Given a queue of stuff to produce, produce it as possible.Squad
- A squad of combat units, which accepts general orders from CombatCommander
and passes more specific orders down to the various micro managers.StrategyManager
- Decide how to spend minerals and gas: Build/research these things in this order, starting with the opening build order and continuing. Fills the queue of MacroAct
objects that ProductionManager
works through. For zerg, it delegates most of the work to StrategyBossZerg
.WorkerManager
- Responsible for most of the stuff that workers do, like mining and repair and self-defense.this version December 2019