-
Notifications
You must be signed in to change notification settings - Fork 178
Installation Instructions
Here you will find step-by-step instructions to install and use UAlbertaBot
UAlbertaBot is currently being maintained using Visual Studio 2019, which is required to open the project file and build the source code. Only use the exact versions of everything listed below.
List of Prerequisites for Bot Compiling:
-
Visual Studio 2019
- Only the C++ related packages are required to compile the bot
-
UAlbertaBot
- Source Code - clone this repo or download it as a .zip file
- I recommend a short directory with no spaces, such as
c:\libraries\ualbertabot
-
Starcraft: Broodwar (version 1.16.1)
- Use this link to install SC, NOT the Blizzard launcher
- Just unzip this file into a folder such as
c:\Games\Starcraft
(no installation required) - Blizzard has given the AIIDE competition permission to re-host the Starcraft game files since the Remaster launch made it impossible to obtain via official means on their website
- Do not attempt to run
StarCraft.exe
on its own, as it probably won't work. You will run the game via theChaoslauncher
program later, with instructions below
-
BWAPI 4.4.0
- Download 4.4.0 stable Release, do not clone the GitHub repo
Install Visual Studio
- Install Visual Studio 2019 from the Microsoft website, which may take several minutes
- Only the C++ development options are required
Install Starcraft
- Install StarCraft: Broodwar version 1.16.1 (this is the only version that will work).
- I highly recommend a short install path with no spaces, such as
c:\Games\Starcraft
- Connecting to battle.net or running any game patcher after this step will break the install, and you'll need to re-install Starcraft from scratch (Note: This refers to connecting to bnet within BW, not the modern bnet launcher program)
Install BWAPI
- Make sure you install BWAPI to a directory without any spaces in its name. This is due to the use of Windows Environment Variables in the UAB project which do not like spaces. I highly recommend
c:\libraries\BWAPI_440
as the directory to install BWAPI 4.4.0 - Either use the BWAPI exe installer, or extract the .7z file to the install directory
- Copy the files from BWAPI's StarCraft folder into your StarCraft install directory
- Copy the files from BWAPI's Windows folder into your StarCraft directory (required dll files)
Windows Environment Variable
- The UAlbertaBot visual studio project makes use of a Windows Environment Variable to find the location of the BWAPI library files. This is done in so that the project can be compiled on any system without any changes to the project file itself.
- Open Start menu, type
env
and the option to edit environment variables appears - Create a Windows Environment variable called
BWAPI_DIR
. The value of this variable should be the BWAPI install directory full path (ex:c:\libraries\BWAPI_440
)
Compile BWAPI 4.4.0
- Open the
BWAPI_DIR/ExampleProjects.sln
VS solution file in VS2019 - For both the
BWAPILIB
andBWAPIClient
projects: Right click on the project, chooseProperties
in the left menu, and changePlatform Toolset
in the right menu toVisual Studio 2019 (v142)
. Be sure to do this for bothRelease
andDebug
Configuration, which are selected in the top-left corner. This step is necessary because BWAPI was originally created using VS2017. - Right click and
Build
theBWAPILIB
andBWAPIClient
projects. This will produce the required LIB files that UAlbertaBot will link against. Be sure to build in bothRelease
andDebug
mode, selected in the toolbar above. - If done correctly, this should create two folders inside the BWAPI install directory:
Release
andDebug
. Each of these folders should now containBWAPILIB.lib
andBWAPIClient.lib
, which will be linked by the UAlbertaBot project in the next step via the Environment Variable value
Compile UAlbertaBot
- Open
UAlbertaBot/VisualStudio/UAlbertaBot.sln
in Visual Studio 2019 - Select
Release
orDebug
mode. TheDebug
version will run much slower, because it keeps track of all variables while running for debugging purposes. If you want to run the bot as fast as possible, selectRelease
.Debug
mode compiles faster, and is recommended for development. - Right-click and
Build
theUAlbertaBot
project (all projects will be built) - The compiled executable file will go to the
UAlbertaBot/bin
directory - Depending on whether compiled in
Release
orDebug
mode, the exe file generated will beUAlbertaBot.exe
orUAlberaBot_d.exe
respectively
In order to use a BWAPI-based bot with Starcraft, you must run Starcraft through the Chaoslauncher
program that comes with BWAPI. Chaoslauncher injects the BWAPI .dll file into Starcraft so that it can communicate with your bot. The executable file for Chaoslauncher is Chaoslauncher.exe
and is located in BWAPI_DIR/Chaoslauncher/
. Chaoslauncher can be run from anywhere on your system, so it is fine to leave it in the BWAPI directory, but I recommend creating a shortcut to it on your taskbar since you will be using it quite often. There is also a multi-instance version which allows you to run multiple simultaneous instances of Starcraft.
- Ensure
Chaoslauncher.exe
andStarcraft.exe
are set up to run as Administrator. Right click the .exe file, selectProperties
>Compatibility
> checkRun as Administrator
- Run
BWAPI_DIR/Chaoslauncher/Chaoslauncher.exe
- Edit the UAlbertaBot configuration file to your liking. By default, the config file is located at
bin/UAlbertaBot_Config.txt
. This file must be in the same directory asUAlbertaBot.exe
. Skip this step unless you are familiar with the bot and its configuration. - Ensure that the
BWAPI 4.4.0 Injector Release
andW-MODE
options are checked in Chaoslauncher - Run
UAlbertaBot
one of two ways: 1) run from VS (by clickingLocal Windows Debugger
above), or 2) by running thebin/UAlbertaBot.exe
file via double-clicking it or running it from a console - The bot should now be running in its own console window, printing
Game table mapping not found
once per second. This will continue until Starcraft is run with BWAPI, at which point the bot will automatically connect to Starcraft and run - Click
Start
in Chaoslauncher to run StarCraft, UAlbertaBot will connect when the game starts - The first time you do step 7, Chaoslauncher may complain that it doesn't know where Starcraft is installed. Click the
Settings
tab on top of the window and edit theInstallpath
directory. - Inside StarCraft, start a game using
Single Player
>Expansion
>Play Custom
, select any standard multiplayer map and useMelee
settings to start. Note: The bot will not work with more than one opponent or in the single player campaign.
Note: By default, the bot executable UAlbertaBot.exe
is compiled and placed in the bin
directory of the UAlbertaBot project. This file can actually be run from anywhere on your system, however it must be in the same directory as the bot's configuration file UAlbertaBot_Config.txt
which by default is also in the bin
directory.
There is a project within the UAlbertaBot Visual Studio Solution file called 'StarterBot'. This project can be used as a starting point if you are interested in developing a Starcraft AI bot from scratch. It contains some sample code on how to connect to the game and do some basic tasks like mine minerals and create your first building. The instructions on how to build and run this bot are the same as the regular UAlbertaBot project.
Once you have everything up and running the first time, I recommend the following workflow:
- Keep Chaoslauncher open while developing, there is no reason to close it
- Edit the
BWAPI.ini
file toAUTO_MENU
on so that you don't have to select Starcraft settings each time the game is run (see below) - After you change the code in VS, simply run the bot by clicking the
Local Windows Debugger
button next to the green arrow in VS, and then click 'Start' in Chaoslauncher. This will first run UAlbertaBot, and then launch Starcraft - Finally, both Starcraft and UAB need to be shut down before you can compile the bot again. You can do this by just closing the Starcraft window, which will automatically stop the
UAlbertaBot.exe
process.
Dev Note: Manually navigating the Starcraft menus becomes very tedious when developing the bot and having to run it multiple times. You can configure the BWAPI.ini
file to use the AUTO_MENU
feature, which will use your input settings to automatically select which map and race to play for you. I recommend getting this to work before starting bot development. To edit the BWAPI.ini
file, first select BWAPI 4.4.0 Injector [RELEASE]
inside Chaoslauncher and then click the Config
button on the right. This will open the Starcraft/bwapi-data/BWAPI.ini
file in notepad.
Full details on the BWAPI config file available here
Debugging errors in a BWAPI bot can be very challenging. Luckily you can make use of Visual Studio's debugger to set break points and step through your code when errors occur. To debug UAlbertaBot simply compile and run the bot in Debug
mode from visual studio, and the debugger will automatically be attached. You can set breakpoints in VS.