A tiny 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
.
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 most 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.
BuildingManager
- Keep a queue of buildings to construct, and construct them, solving any problems (“oops, that spot turned out to be blocked”). Takes its orders from ProductionManager
.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.CombatCommander
- In charge of squads and overall tactics. Passes orders to Squad
objects.InformationManager
- Keeps track of units (especially enemy units that have been seen), bases, and so on.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.Micro
- Sends commands to units, being careful not to spam commands.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 style.ParseUtils
- Read the configuration file and set configuration variables to match. If you want to add a new configuration variable, put 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. Creates the queue that ProductionManager
works through.WorkerManager
- Responsible for most of the stuff that workers do, mining and building and repair.this version February 2018