In order to make building / customizing BWAPI AIs easier for non-developers (and developers of course), my bot - krasi0 - now accepts user defined Build orders (BOs) and other settings from .txt files.

* Updates:v 2.21 - lots of bugfixes and improvements in both micro and macro playv 2.20.12 - added support for picking a random BO file, e.g. if the match up is tvp and say you have the following files tvpMecha1.txt, tvp22.txt & tvp.txt, the bot will pick a random one of them. Each file must begin with tvX and end in .txt (where X is one of the following t, p z); a fix in scoutManager;v 2.20.11 - a fix in buildingPlacer; added support for match up specific settings files, e.g.scoutManager_tvp.txt which is executed after scoutManager.txt and overrides any settings that were set in the latter but ONLY for the tvp match up. see atchment bwapi-data_sample_v4.zipv 2.20.10 - an important fix in repairerManagerv 2.20.9 - some updates in siege tank micro and repairerManagerv 2.20.8 - added gameSpeed cmd in common.txt settings file; try to save workers if more than 2 enemy units attack an expansion; lowered requirements to auto upgrade tank and vulture techs if they were skipped for some reason; some unsiege micro logic updates; v 2.20.7 - added more configuration in defenseManager.txt settings file; see attachmentv 2.20.6 - added support for scoutManager & workerManager settings files; these need to be put into `bwapi-dataAIkrasi0settings` directory; see attachment bwapi-data_sample_v1.zip (check for the new command settings inside them - the list will grow with time); Fixes in repairManager; v 2.20.5 - implemented two new commands: enableBunkerRepairers & setRepairerCountv 2.20.4 - many new commands are now supported in a BO file. See the next post for detailsv 2.20.2 - removed a constraint that didn't allow to fast expand before the 5000th game framev 2.20.1 - fixed some inconsistencies when parsing tvz & tvp BOs; added second parameter to expand command; fixed support for U_238_Shells Terran upgrade-------------------------------------------------------------------------------------------------------------Contributed BOs topic-------------------------------------------------------------------------------------------------------------Download current version 2.21 - you need the whole contents of the zip file . Have a look also at Attached files

Contact me at `krasi[put tripple zero here] at gmail` or post a reply here for feedback!The syntax of a BO file is explained in details in the next post (have a look at the tvp.txt BO script for sample usage of build orders and the rest of the commands). In the future I'll add support for fine-grained tunability of the bot, e.g. control of micro, etc.

Notes: 1) in order to edit a BO or a settings file use a utf-8 capable text editor, e.g. notepad++2) If the syntax of a BO file is broken, it'll probably make the bot crash or the BO will go to hell and bot economy development will stall.3) if after some time anyone wishes to contribute his / her very successful BOs (and settings files when those are supported), it'll be distributed along with the bot with the respective credits of the author of course 4) to create even more clutter , in the following posts I'll explain different supported commands, settings.5) At some point I'll probably create a desktop GUI application or a web interface for easier editing of Build Orders or any other settings.6) To test your modified Build Order / settings quickly, you can start a single player game (vs the computer) and type /speed 0 at the console, this will speed the game a lot and you'll see your BO executing in seconds.7) one normal game second contains very close to 24 game frames, so when considering timings in your BO, do the calculations in game frames, like for the expand command in the next post.8) someone with access to powerful enough hardware might consider using GAs (genetic algorithms) to find optimal build orders vs another bot / BO9) If the game freezes after the start, this is because BWTA analyzes the map. It should take less than a minute to complete so please be patient. It'll be cached for later games.

The build orders are to be defined in a .txt file, say tvp.txt, and need to be put in the directory (which you should create) bwapi-dataAIkrasi0build_ordersThe semantics of a BO file follows approximately BWSAL (http://code.google.com/p/bwsal/) (which you don't need to be familiar with). Attached are also sample BO files - inside bwapi-data_sample_v1.zip.If everything went on well, after a game start the bot will find the .txt file and output which user defined BO it uses.These days I'll implement random choice between a number of BOs. That is, if at the start of the game the bot detects there are the following BO files, tvp1.txt, tvp3.txt, tvp4.txt, it will randomly execute one of them, giving the opponent some surprise of what to expect.You don't need to restart the Broodwar application for a change in a BO file. At the start of the next game, the updated BO file will be reread and executed.If a command in a BO file is misspelled, the bot will show a notice at game start about an unsupported build order command.

Currently supported build order commands.

1) --prio - decreases the priority of any following build orders, i.e. in order for a build order defined below the --prio cmd to start executing, the ones before the --prio command need to have already been dispatched for execution. This is not 100% strict though and sometimes events may overlap or change places chronologically. For simplicity imagine that at the top of the script the priority is 60. Any build / upgrade command before the first --prio command will have priority of 60. After the first --prio cmd and before the next --prio cmd, all build / upgrade cmds will have priority of 59. In between the second --prio cmd and the third --prio cmd all build / upgrade cmds will have priority of 58 and so on on subsequent levels...

2) buildAdd - instructs the AI to add X more units / buildings of the given type at the current priority level. This is the most commonly used and recommended command.Example: buildAdd 11 Terran_SCV - adds 11 MORE SCVs to the build queue at the given prio level

3) build - instructs the AI to consider X total units / buildings of the given type at the current priority level. Not recommended for usage.Example: build 11 Terran_SCV - enqueues 11 total SCVs to the build queue at the given prio level so any previous build(Add) commands related to the current priority level are overwritten

4) buildTotal - instructs the AI to consider X total units / buildings of the given type erasing any previous build commands regarding this unit type at any other prio level. Not recommended for usage.Example: buildTotal 11 Terran_SCV - will try to have only 11 total SCVs, replacing any other enqueued cmds for building SCVs

5) expand <frame_count> - tells the bot to expand at the given priority. The <frame_count> parameter needs to be replaced with an integer number, say 3200 (around 130 seconds into the game), representing the earliest game frame when the AI would start considering to save resources for the expansion. A good value is about 2000-3000 frames before the start of the construction of the command center although this is highly approximate. For example if according to your BO, the expansion CC would start to be built at the 6000th frame, setting this to 3200 seems reasonable. A rule of thumb on how to calculate this value is: play the build up to constructing the expansion command center yourself. Check at exactly which second you start the construction. If it's 3:24 minutes after the game start, we have 204 seconds, we multiply this by 24 (the game runs on normal speed at 24 FPS) and we get approximately 4900 frames. We subtract 2500 and get 2400 which is 2500 when rounded, so we construct the command as follows:expand 2500

7) setToBionic - informs the AI that is should prefer building bionic units (marines, medics, firebats) rather than building tanks / goliaths / vultures.

8) setToMecha - like the above but prefers building mecha units (tanks / goliaths / vultures) rather than bionic

9) armyStrengthL1 <unit count> - This is L1 attack stage. <unit count> tells the AI how many war units (marines, vultures, tanks, etc.) to send to the enemy as the initial harrasment attack. If <unit count> is set to 1, for example, it will send the first marine it builds directly to the enemy base.

10) armyStrengthL2Prepare <unit count> - This is L2 attack stage or the first serious attack towards the enemy. Tells the AI how many war units (marines, vultures, tanks, etc.) it needs to gather before starting to attack move towards the enemy base. If during the L2 attack stage, the bot has lost most of its army on the way and now have less than <unit count> - 2-3, it will retreat to its main base.

11) armyStrengthL2Attack <unit count> - This is again L2 attack stage. It tells the AI how many war units (marines, vultures, tanks, etc.) it needs to have the least in order to start marching towards the enemy base. It will gather its army in front of the enemy base though. It won't attack until reached L3 all-in army counts or definitely feels that it has a lot greater army than the enemy.

12) armyStrengthL3Prepare <unit count> - This is L3 attack stage or the second serious attack towards the enemy (if the first one was unsuccessful). Similar logic as L2 Prepare but with greater army numbers.

13) armyStrengthL3Attack <unit count> - This is again L3 attack stage. Similar logic as L2 Attack but with greater army numbers.

14) armyStrengthL3AllIn <unit count> - tells the AI how many war units (marines, vultures, tanks, etc.) it needs to have in order to attack (at last) the enemy main base or any expansion on the route there

Note: regarding the above commands - the bot has some built-in heuristics and If it has scouted that the enemy army is a lot stronger, it won't transition to the next level of attack until it detects it's stronger. This, of course, depends on good scouting.Some example values for the above commands vs a Zerg when we go bionic and FE are:armyStrengthL1 1armyStrengthL2Prepare 16armyStrengthL3Prepare 22armyStrengthL2Attack 20armyStrengthL3Attack 26armyStrengthL3AllIn 32

15) aggressiveBunkers <0 or 1> - 1 means enabled, 0 - disabled. Tells the AI to try to build bunkers near the enemy base when attacking. This functionality is not very reliable and complete. Might be useful when containing a zerg player. Experimental...

16) tankPush <0 or 1> - if enabled, will try to shorten the attackOuterCheckpointTranslation by 1 tile length, e.g. will try to push closer towards the enemy when containing her. This happens before it reaches armyStrengthL3AllIn and is still in Attack phase. Note that the availability of siege tanks is not needed.

17) goNuclear <0 or 1> - whether to try to launch nuclear strike on the enemy buildings / units. This happens only in very late game vs not very strong opponents.

18) rush <0 or 1> - if enabled makes the armyStrengthL2Attack all-in and never tries to retreat towards its main base.

19) attackOuterCheckpointTranslation <number in px> - that's how far from the enemy's natural base chokepoint the army would gather when in attack stage. If you imagine the containment situation against zerg, that's where the marines and tanks would gather before pushing towards the zerg expansion. If there are sunkens, for example, it the translation will automatically move some distance back. Note again that it's from the natural chokepoint center andnot the opponent's nexus / hatchery... Sensible values are: low values (about 160 px) vs Zerg, medium (260 - 450 px) vs P, and greater ( 450 - 550 px) vs Terran

20) performUnitsDropTime <frame number> - the number of frames when the bot will start preparing for a units drop, e.g. if it doesn't have a starport, it will build one, if it doesn't have a dropship, it will build one, load 4 vultures, etc. If you want to disable such drops, put a value of 900000 here.

21) unitsDropEarly <0 or 1> - if enabled, increases priority for units drop and in result they occur earlier.

22) chokeSCVs <-1 or greater up to 6> - if the base chokepoint is narrow enough and you don't FE (fast expand), you could use this setting to create an SCV "wall" so that melee units like zealots won't pass in unless they kill the SCVs. -1 tells the bot to try to calculate on its own how many SCVs are needed. 0 disables the setting and 1 - 6 force the bot to use the specified number of SCVs. -1 or 0 are recommended depending on whether to BO includes a FE.

23) useScoutBarracks <0 or 1> if enabled will lift a barracks and use it to give greater vision to the army when attacking the enemy. Suitable vs Terran

24) useScoutEngBay <0 or 1> - the same as above but uses an Eng bay. Suitable vs Protoss

25) useScoutBuildingEarly <0 or 1> - if enabled and one of the prev two commands is set, lifts the building right away when it's ready and sends it to monitor the enemy base. This is an earlier form of scouting.

26) postRushMarines <count> - how many marines to urgently build if rushed early in the game and lost all it's defenses

27) enableBunkerRepairers <0 or 1> - by default is enabled. If disabled, will never send repairers to guard a bunker when it's NOT under attack. It would still be repaired if damaged.

28) setRepairerCount <count> - specifies the minimal number of reserved repairers standing close to the chokepoint before our first initial marching attack towards the enemy.

Note: All commands after 6) have some sensible defaults so one doesn't need to specify them explicitly. It'll be good to do so in order to improve the bot's play though.

Important:The supplied BOs are available for free to use, test, improve and experiment with.If you use or improve another author's BO file, please leave the original credits inside the file to respect other people's work!I invite anyone who has achieved anything useful, to contribute here.