This repository is originally based on several years old version of StarCraftAITournamentManager by Dave Churchill and Rick Kelly from https://github.com/davechurchill/StarcraftAITournamentManager. It still contains a considerable amount of its original code.
This particular implementation is currently (as of 2022) used to run Student StarCraft AI Tournament (SSCAIT): http://sscaitournament.com/
- Tournament Module DLL that's injected to StarCraft process and controls the camera, timeouts and results: https://github.com/certicky/sscait-tournamentmodule
- Web frontend for the tournament that displays the game schedule and bot scores and allows bot authors to upload their bots: https://github.com/certicky/sscait-web (live at https://sscaitournament.com)
- One host machine, where the server and the database are running. SSCAIT host runs on Ubuntu Linux server, but it should probably work almost anywhere.
- Two client Windows 7 machines. SSCAIT runs two Windows 7 virtual machines directly on the host. Each sould be able to:
- Run Java client app.
- Run StarCraft.
- Connect to the server app running on the Host machine via local network or the internet.
- Connect a folder from the host machine as a windows network drive.
- Connect to the other Client machine, so they can play StarCraft LAN games.
-
Clone this repo to preferred location on your Host machine.
-
Install Java. On the host, it's not important whether Java is 64-bit or 32-bit (only the client machines need to use 32-bit Java).
-
Install MySQL database server (note: versions since about version 8 aren't compatible with the driver, but 5.7 works) and create a database called
sc.- After installing MySQL, it is recommended to run
sudo mysql_secure_installationto secure the MySQL installation by answering the prompts, e.g. require strong passwords, remove anonymous users, disallow root login remotely, remove test database and access to it, reload privilege tables. - Create a user with read & write permissions to that database.
- Import/run the
database.sqlfile to create the required DB tables, such asgames,fos_user,achievements, etc.
- After installing MySQL, it is recommended to run
-
Create a
Botsfolder somewhere on your Host machine. -
Get a few bots that you want to run and:
- Edit the rows in
fos_userDB table to correspond to those bots. Don't forget to set the correctbot_race,bot_pathandbot_type.bot_racesupports valuesTerran,Zerg,ProtossandRandombot_typesupports valuesEXE,AI_MODULE,JAVA_MIRRORandJAVA_JNIbot_pathmust be an absolute path to specific bot's binary within yourBotsfolder.- RULE: Use the
/character as the folder separator (not e.g.\or\\). - RULE: The filename only supports space characters for
AI_MODULEbots. ForJAVA_MIRROR/JAVA_JNI/EXEbots, the filename can not contain space character(s), so e.g. renameFooBar Bot.exetoFooBar_Bot.exeand updatebot_pathaccordingly. - RULE: Each bot must have its own subfolder under
/Bots/named by theiridfromfos_usertable. For example, the bot with ID3can have thebot_pathset to something like/home/exampleUser/Bots/3/AI/StarterBot.exe(notice that its subfolder is called3like their DBid).
- RULE: Use the
- Set up the subfolders of individual bots. Subfolder of each bot needs to:
- Be named after its DB id.
- Be placed directly inside the Bots folder.
- Contain subfolder
AIthat contains its binary and correct version of BWAPI.dll. Example:/home/exampleUser/Bots/3/AI/StarterBot.exeand/home/exampleUser/Bots/3/AI/BWAPI.dll - Contain subfolders
readandwrite. These are used if the bot needs to read and write some additional persistent files (e.g. when the bot learns something about specific opponents). - Some bots (e.g. Bereaver) might require some files to be placed into the
readfolder (strategies.jsonin Bereaver's case), as opposed to into theAIfolder.
- Edit the rows in
-
Go to
host_folder_serverfolder. This is the folder from which your server will run.- Make a copy of
server_settings.ini.templatefile calledserver_settings.iniin thehost_folder_serverfolder. - Update the settings in your newly created
server_settings.inifile like this:ServerRequirementsDirshould be an absolute path tohost_folder_server/server_requirementson your Host machine.BotsDiris an absolute path to your Bots folder.ReplaysDiris an absolute path to any folder on your Host machine, where you want the replays to be stored. Make sure that the folder exists and that the user running the server has write permissions there.LogFilePathis an absolute path to a text file where the server stores some logs. Make sure the user running the server has write permissions there.Database*are 5 variables holding the credentials of your MySQL DB and a DB user with access to thescdatabase.GmailFromEmailandGmailEmailPasswordare a credentials of a real Gmail user, which is used to send emails to bot authors (disabled by default) or to the admin (you).TM*are 10+ variables that are propagated to Client machines and control various aspects of StarCraft games that run on the client, such as game speed, time limits, screen resolution and camera movement. Feel free to leave defaults there.
- Make a copy of
- Go to
host_folder_server. - Run
java -jar sscai-server.jar server_settings.ini - Server's GUI window should appear and it should start waiting for client connections. The first time you run it, it might exit after it writes a log message saying that it needs to be rerun after it added some games to the games list, so if this happens, rerun it. Security software like Windows Security may also pop-up asking about blocking it, so unblock it if this happens.
- Make sure you have two Windows 7 machines prepared. SSCAIT uses two Windows 7 VMs running on VMWare Workstation, but you can use different virtualization software, or even physical machines.
- Make sure both Client machines have network access to the Host and to each other, so they can communicate with the Java server and play StarCraft via LAN.
- Mount the
host_folder_clientfolder from the Host machine as a Windows network drive, so that its contents are accessible under pathZ:\Client\. It should preferably be mounted read-only, so that the bots can't mess with the files. You might need to create some symbolic links on the Host machine to make this work. You should now have access to folders likeZ:\Client\additionalRequirements\andZ:\Client\chaoslauncher\. - Create a folder
C:\TM\on your Client machines. - Copy the contents of
client_copy_to_VMtoC:\TM\. You should now have a fileC:\TM\client_settings.ini.templateon your Client machines. - Make a copy of
C:\TM\client_settings.ini.templateand save it asC:\TM\client_settings.inion both machines. Edit the new settings file as follows:ServerAddressshould point to the IP of the Host machine, where the server is running (and a port on which it listens for connection - this is 4499 if you haven't changed it in server settings).
- Install or put a copy of the StarCraft 1.16.1 program folder at
C:\TM\Starcraft\. There should now exist a fileC:\TM\Starcraft\StarCraft.exeon your Client machines. - Install 32-bit Java on your Client machines. If multiple versions are installed, ensure that the "java" command uses a 32-bit version (not a 64-bit version).
- Install the following versions of Microsoft Visual C++ Redistributable. All need to be the 32-bit version (not 64-bit), although you can have the 64-bit version of each installed too without problems. At the time of writing, the latest supported downloads are available from Microsoft from https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist
- Install the 32-bit Microsoft Visual C++ Redistributable for Visual Studio 2015-2019+, e.g. 2015-2022.
- Install the 32-bit Microsoft Visual C++ Redistributable for Visual Studio 2008 (VC++ 9.0) SP1.
- Some security software like Windows Security may identify some BWAPI-related tools/bots as malware, so consider adding security software exclusions for drives/folders
C:\TM,Z:\. - If the machine is not a VMWare VM, create a dummy EXE file (and any necessary parent folders) at
C:\Program Files\VMWare\VMWare Tools\VMWareResolutionSet.exe, e.g. by copyingC:\Windows\System32\rundll32.exe(which simply exits).
-
Run
Z:\Client\setupAndRun.baton both Client machines. This should get the Java Client app JAR and additional requirements from the Host machine and run the Java Client app. Ajava.net.UnknownHostException: sscaitournament.comexception is shown for every message shown in the CMD window but you can ignore them.- The Java Client app should start up in a new commandline window, where you'll see debug messages. It will connect to the Host server.
- Once both Clients are connected to the server, they will receive the bot files, the map, and the instruction to run the game.
- The Java Clients will run the bot files they received from the server (or inject them into StarCraft process in case of DLL bots).
- The first time each machine uses each individual version of BWAPI, a Chaoslauncher window appears because it needs to know which plugins and settings to use, so check the corresponding BWAPI injector plugin (Release mode if there is a choice), and check any other desired plugins (the RepFix & WMODE plugins are recommended), and in the Settings tab, check "Start Chaoslauncher minimized" and check "Minimize when running Starcraft" and check "Run Starcraft on Startup" and uncheck "Warn about missing adminprivilegues", then click the "Start" button.
- One of the Clients will create a game and the other will join.
- The game will start.
- Once the game ends, both Java Clients will report the game result to the server.
- The clients will clean up the bot files after the game.
- The server will save the game result in
gamesDB table on the Host machine. - The server will get the new game from the schedule in
gamesDB table and send new bot files & instructions to the Clients. - And the whole process repeats.
-
If desired, set up the machine so that it runs
setupAndRun.batwhen Windows starts.- WARNING: the machine should be restarted prior to ever rerunning the Java Client app, even if everything appeared to shut down and clean up gracefully, because it's possible that bot process(es) may still be running from previous games that could cause problems for new games. If this happens, a common problem is that one or both bots may not start: the game may appear to run smoothly but the bot(s) don't issue any commands during the game. When the Java Client app starts, although it does try to kill any StarCraft processes that are still running, it does not try to kill other bot process(es) that may be still running from previous games - especially Java bots and EXE bots, but any bot that runs separate process(es) than StarCraft.exe, e.g. CherryPiSSCAIT2017 which is a DLL bot (
AI_MODULE) that also spawns an EXE process. Some DLL bots run a separate EXE to find good building placements to wall off their ramp/choke.
- WARNING: the machine should be restarted prior to ever rerunning the Java Client app, even if everything appeared to shut down and clean up gracefully, because it's possible that bot process(es) may still be running from previous games that could cause problems for new games. If this happens, a common problem is that one or both bots may not start: the game may appear to run smoothly but the bot(s) don't issue any commands during the game. When the Java Client app starts, although it does try to kill any StarCraft processes that are still running, it does not try to kill other bot process(es) that may be still running from previous games - especially Java bots and EXE bots, but any bot that runs separate process(es) than StarCraft.exe, e.g. CherryPiSSCAIT2017 which is a DLL bot (
-
(optional) You can use OBS (in
C:\TM\OBS\) to stream what's happening on Client machines. -
(optional) You can use some of the AHK scripts (if you install AutoHotKey) on the Client machines to auto-close windows error messages, to control OBS, etc.
-
(optional) You can use Chromium (
C:\TM\Chromium\run_chromium.bat) to display the game schedule on the Client machine (makes sense when also streaming).
- At the time of writing, if you are developing for the current environment at sscaitournament.com, Java 8 can be used/targeted when building JARs (i.e. without needing to upgrade Java on those machines when deploying).
- You're mainly interested in the Java source files in folders:
server,client,objects,utility(there are some additional dependencies inlib) - Host app needs to be built as a JAR file
host_folder_server/sscai-server.jarto be properly used. It needs to contain all the dependencies, so it's runnable as a standalone JAR from anywhere. You can prepare and test the runnable JAR using these commands:- Run to compile all the .java files:
javac -cp "lib/*" server/*.java client/*.java objects/*.java utility/*.java - Run to create a runnable JAR file:
jar -cvfm host_folder_server/sscai-server.jar config/Manifest_Server.txt client/*.class objects/*.class utility/*.class server/*.class org/eclipse/jdt/internal/jarinjarloader/*.class ./mysql-connector-java.jar ./javax.mail.jar - Run on the host to test:
java -jar host_folder_server/sscai-server.jar host_folder_server/server_settings.ini
- Run to compile all the .java files:
- Client app needs to be built as a JAR file
host_folder_client/sscai-client.jarto be properly used. It needs to contain all the dependencies, so it's runnable as a standalone JAR from anywhere. You can prepare and test the runnable JAR using these commands:- Run to compile all the .java files:
javac -cp "lib/*" server/*.java client/*.java objects/*.java utility/*.java - Run to create a runnable JAR file:
jar -cvfm host_folder_client/sscai-client.jar config/Manifest_Client.txt client/*.class objects/*.class utility/*.class server/*.class org/eclipse/jdt/internal/jarinjarloader/*.class ./mysql-connector-java.jar ./javax.mail.jar - Run on the Windows machine to test:
java -jar sscai-client.jar client_settings.ini
- Run to compile all the .java files: