Giter Site home page Giter Site logo

bwapi-c's Introduction

bwapi-c

Build Status Build status release

C language bindings to the BWAPI library

BWAPI again? Why?

The original BWAPI.dll is written in C++. Due to mangling etc... you can't link against BWAPI.dll with other compilers but only with cl.exe and link.exe. The goal of this library is to provide a minimalistic C API which can be used to create bindings for high-level languages.

Build on Linux

bwapi-c/ $ mkdir build && cd build
bwapi-c/build $ cmake .. -DBWAPI_PATH=~/Downloads/BWAPI
bwapi-c/build $ make

BWAPI_PATH must point to directory with BWAPI release.

Usage on Linux with GCC for BWAPILauncher

You should get libBWAPIC.so that was build on Linux with GCC. See Releases.

Module

~/bwapi-c/example $ ls
libBWAPIC.so Dll.c
~/bwapi-c/example $ gcc -shared -fPIC -o Dll.so Dll.c -I../include -L. -lBWAPIC
~/bwapi-c/example $ ls
Dll.c Dll.so libBWAPIC.so

Put libBWAPIC.so and Dll.so inside BWAPILauncher directory, copy BrooDat.mpq, Patch_rt.mpq, StarDat.mpq, maps from StarCraft directory. Set up bwapi-data/bwapi.ini (unset ai, ai_dbg, set map, e.g. map=maps/BroodWar/ICCup Tau Cross.scx) and run:

~/openbw/bwapi/build/bin$ BWAPI_CONFIG_AI__AI=Dll.so BWAPI_CONFIG_AUTO_MENU__RACE=Zerg ./BWAPILauncher

Troubleshooting

If you are getting dlerror while injecting your module inside BWAPILauncher, recompile bwapi-c on you local machine and recompile your Dll.so.

Possible errors:

dlerror: libBWAPIC.so: undefined symbol: _ZNK5BWAPI5Event7getTextB5cxx11Ev

This is caused by different compiler flags on your machine. libBWAPIC.so was built with --with-default-libstdcxx-abi=new, and your compiler is probably --with-default-libstdcxx-abi=gcc4-compatible --disable-libstdcxx-dual-abi. Recompiling OpenBW and bwapi-c with the same compiler will fix this problem.

Client

You may compile it, but it is not supported by OpenBW for now.

Usage on Linux with MinGW for StarCraft.exe

You should get BWAPIC.lib, BWAPIC.dll and BWAPI.dll that was build on Windows with MSVC. See Releases.

Module

~/bwapi-c/example $ ls
BWAPIC.lib Dll.c
~/bwapi-c/example $ i686-w64-mingw32-gcc -mabi=ms -shared -o Dll.dll Dll.c -I../include -L. -lBWAPIC
~/bwapi-c/example $ ls
Dll.c Dll.dll BWAPIC.lib

Put BWAPIC.dll inside StarCraft directory and Dll.dll inside StarCraft/bwapi-data. Set up bwapi.ini (ai=bwapi-data/Dll.dll) and run:

$ wine bwheadless.exe -e StarCraft.exe -l bwapi-data/BWAPI.dll --headful

Client

~/bwapi-c/example $ ls
BWAPIC.lib Client.c
~/bwapi-c/example $ i686-w64-mingw32-gcc -mabi=ms -o Client.exe Client.c -I../include -L. -lBWAPIC
~/bwapi-c/example $ ls
BWAPIC.lib Client.c Client.exe

Put Client.exe into a directory with BWAPIC.dll and BWAPI.dll. Run in the first terminal:

~/bwapi-c/example $ ls
Client.exe BWAPIC.dll BWAPI.dll
~/bwapi-c/example $ wine Client.exe 
fixme:module:load_library unsupported flag(s) used (flags: 0x00000800)
...
fixme:ntdll:EtwEventRegister ({5eec90ab-c022-44b2-a5dd-fd716a222a15}, 0x2a27f0, 0x2b0030, 0x2b0048) stub.
fixme:ntdll:EtwEventSetInformation (deadbeef, 2, 0x2a2560, 43) stub
Reconnecting...
Game table mapping not found.
...

Set up bwapi.ini (comment out ai=... and ai_dbg=...) and run in the second terminal:

$ wine bwheadless.exe -e StarCraft.exe -l bwapi-data/BWAPI.dll --headful

Switch to the first terminal, you shall see:

...
Game table mapping not found.
0 | 62 | 0 | 36406654
1 | 0 | 0 | 0
2 | 0 | 0 | 0
3 | 0 | 0 | 0
4 | 0 | 0 | 0
5 | 0 | 0 | 0
6 | 0 | 0 | 0
7 | 0 | 0 | 0
Connected
Connection successful

Open Starcraft gui window, start a game or replay, the client in the first terminal will report you:

Connected
Connection successful
Starting match

bwapi-c's People

Contributors

0x7cfe avatar kpp avatar nlinker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

mikailbag

bwapi-c's Issues

Support language GOAL

matisup10: Hi guys! I've got a question for you. For our study (ComputerScience bachelor at TU Delft, Netherlands) we are programming bots in the language GOAL (with like 40-50 teams), is there any chance that we can enter your tournaments with this programming language?

@matisup10 Hi! With this library you are able to implement bots in GOAL

How can I help?

Hi guys, I'd like to contribute, is there something not done yet?

Wrap filters

We need to implement:

  • Game_getUnitsOnTile
  • Game_getUnitsInRectangle
  • Game_getUnitsInRadius
  • Game_getClosestUnit
  • Game_getClosestUnitInRectangle
  • Game_getBestUnit
  • Region_getUnits
  • Unit_getUnitsInRadius
  • Unit_getUnitsInWeaponRange
  • Unit_getClosestUnit

Wrap lists

We need to implement:

  • Game_getStartLocations
  • Game_getNukeDots
  • Game_getEvents
  • Unit_getTrainingQueue

compile Dll.dll on Mac OS X

I'm trying to build and compile bwapi-c on Mac OS X and ran into an issue with the Dll.dll module. This is the message I receive from i686-w64-mingw32-gcc. The gcc was installed from https://github.com/cosmo0920/homebrew-mingw_w64.

$ brew tap cosmo0920/mingw_w64
$ brew install-mingw-w64
$ brew install i686-w64-mingw32-gcc
$ i686-w64-mingw32-gcc -mabi=ms -shared -o Dll.dll Dll.c -I../include -L. -lBWAPIC
/var/folders/ww/mp9fm43j4017vxnz2cf_xw600000gn/T//ccBjd3YT.o:Dll.c:(.text+0xe1): undefined reference to `Game_setTextSize'
collect2: error: ld returned 1 exit status

Maybe all isn't necessary to use bwapi-sys and bwapi-rs - just trying to figure out how it all fits together.

How can I help?

Hi guys, I'd like to contribute, is there something not done yet?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.