MonoBridge Setup - suegy/bwapi-mono-bridge2 GitHub Wiki

BWAPI-MonoBridge-Setup

If you have setup StartCraft and BWAPI you can continue here to configure the bridge to develop StarCraft AI in C#*

following steps are assumed to have been done:

  • StarCraft installed and patched to 1.16.1
  • BWAPI 3.7.4 downloaded and extracted, let's assume it is extracted to C:\Users\[User]\Documents\Projects\BWAPI
  • Visual Studio 2010 (express) installed
    • if you want to debug your bot you also need to install Visual Studio 2008 express (ChaosLauncher needs VisualStudio 2008 for the injector to work otherwise it will complain)

Building a Bridge (Part a):

  • in your BWAPI folder create a folder called bwapi-mono-bridge2
  • either dowload the BWAPI Bridge as an archive and extract in the bwapi folder into the bridge folder or git clone https://github.com/suegy/bwapi-mono-bridge2.gitinto the same folder
  • patch the following file BWAPI 3.7.4\include\BWTA\RectangeArray.h:
175  void RectangleArray<Type>::setItem(unsigned int x, unsigned int y, Type* item)
176  {
177  -- this->getColumn(x)[y] = item;
177  ++ this->getColumn(x)[y] = *item;
178  }

218  for (unsigned int x = 0; x < this->getWidth(); x++)
219  {
220  --      char ch = this->getColumn(x)[y];
220  ++      char ch = (char) this->getColumn(x)[y];
221        fprintf_s(f, "%c", ch);
222  }

Now you have two options either building the bridge yourself from source or to continue from here.

Building a Bridge (Part b):

  • to build a wrapper for BWAPI (written in C++) to be used with [POSH-sharp] or any other framework written in Csharp you could either wrap every class yourself or automate this using SWIG. Because its way easier to maintain we are using SWIG.
  • the bridge was tested with SWIG 3.0.5 and 2.0.9, so best download SWIG 3.0.5
  • extract SWIG somewhere you can remeber, again let's assume you put it here: C:\Program Files (x86)\swigwin-3.0.5
  • your bridge folder (C:\Users\[User]\Documents\Projects\BWAPI\bwapi-mono-bridge2) contains three sub-folders:
    • required contains bits'n'bobs you might need to set everything up. I collected some of those external dependancies in case a server goes dark
    • Source contains everything we need to build the bridge and a template bot class
    • Release comes with a pre-build bridge so if you don't want to build it yourself you can skip the next step and continue after build here
  • navigate into Source\Common\SWIG
  • with an editor open the batch file BuildInterface.bat
    • change the SWIGPATH=[path] to where you extracted your swig archive to and save this change

NOTE: SWIG can creates wrappers for other languages such as Java,python, ruby, R and Prolog as well, the only thing which needs changing is to change the option -csharp in the Buidlinterface.bat to the disired language and then check if there are additional changes needed. Java and Csharp should work without any changes.

  • open a command promt and navigate to the BuildInterface.bat and execute it.
  • If everything works Csharp class files should be created in Classes and the three C++ wrapper classes should be in Wrappers.
    • if the build does not work check the command log in the promt if nothing is visible and no files are created check your firewall and virus scanner setting that swig.exe is not blocked

Now everthing is in place for building your own Csharp based agent using the BWAPI-mono-Bridge2. Continue here for setting up an StarCraft agent.

⚠️ **GitHub.com Fallback** ⚠️