Skip to content

Commit 44858ae

Browse files
authored
Merge pull request #73 from JavaBWAPI/linux-support
Linux support
2 parents 36754c2 + 58cf01e commit 44858ae

File tree

14 files changed

+464
-144
lines changed

14 files changed

+464
-144
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test Linux
2+
3+
on:
4+
- pull_request
5+
6+
jobs:
7+
e2e:
8+
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up JDK 8
14+
uses: actions/setup-java@v2
15+
with:
16+
java-version: '8'
17+
distribution: 'temurin'
18+
cache: maven
19+
- name: Build with Maven
20+
run: mvn -B package --file pom.xml
21+
22+
- name: Setup and launch openbw
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install cmake libsdl2-dev libsdl2-mixer-dev
26+
27+
git clone https://github.com/basil-ladder/openbw
28+
git clone -b linux-client-support https://github.com/basil-ladder/bwapi
29+
cd bwapi
30+
mkdir build
31+
cd build
32+
cmake .. -DCMAKE_BUILD_TYPE=Release -DOPENBW_DIR=../../openbw -DOPENBW_ENABLE_UI=1
33+
make -j4
34+
35+
curl http://www.cs.mun.ca/~dchurchill/starcraftaicomp/files/Starcraft_1161.zip -o starcraft.zip
36+
unzip starcraft.zip patch_rt.mpq BROODAT.MPQ STARDAT.MPQ
37+
mv patch_rt.mpq Patch_rt.mpq && mv BROODAT.MPQ BrooDat.mpq && mv STARDAT.MPQ StarDat.mpq
38+
unzip starcraft.zip "maps/BroodWar/ICCup/ICCup Destination 1.1.scx"
39+
40+
BWAPI_CONFIG_AUTO_MENU__RACE=Terran BWAPI_CONFIG_AUTO_MENU__MAP="maps/BroodWar/ICCup/ICCup Destination 1.1.scx" ./bin/BWAPILauncher&
41+
BWAPI_CONFIG_AUTO_MENU__RACE=Terran BWAPI_CONFIG_AUTO_MENU__MAP="maps/BroodWar/ICCup/ICCup Destination 1.1.scx" ./bin/BWAPILauncher&
42+
43+
- name: Build & Run test bots
44+
run: |
45+
mvn install -DskipTests
46+
mvn -f it/bots/pom.xml package
47+
48+
java -jar it/bots/SittingDuck/target/SittingDuck-*-jar-with-dependencies.jar &
49+
sleep 3
50+
java -jar it/bots/jbwapibot/target/MarineHell-*-jar-with-dependencies.jar | grep "Hello from JBWAPI!" || exit 1
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test Wine
2+
3+
on:
4+
- pull_request
5+
6+
jobs:
7+
e2e:
8+
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up JDK 8
14+
uses: actions/setup-java@v2
15+
with:
16+
java-version: '8'
17+
distribution: 'temurin'
18+
cache: maven
19+
- name: Set up Python 3.6
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: '3.6'
23+
24+
- name: Build with Maven
25+
run: mvn -B package --file pom.xml
26+
- name: Show versions
27+
run: |
28+
uname -a
29+
python3 --version
30+
java -version
31+
- name: Setup e2e-windows environment
32+
run: |
33+
git clone https://github.com/Bytekeeper/sc-docker.git
34+
cp it/sc-docker-support/*.dockerfile sc-docker/docker/dockerfiles
35+
pushd sc-docker
36+
pip3 install numpy==1.16.6 wheel
37+
python3 setup.py bdist_wheel
38+
pip3 install dist/scbw*.whl
39+
cd docker
40+
./build_images.sh
41+
popd
42+
cp sc-docker/scbw/local_docker/starcraft.zip /tmp/sc-docker/starcraft.zip
43+
scbw.play --install
44+
45+
- name: Test the e2e-windows environment
46+
run: |
47+
sh mvnw clean install
48+
sh mvnw -f it/bots/pom.xml package
49+
for bot in $(ls -d it/bots/*/); do BOTNAME=$(basename $bot); echo "Setting up $BOTNAME"; mkdir -p "$HOME/.scbw/bots/$BOTNAME/AI" "$HOME/.scbw/bots/$BOTNAME/read" "$HOME/.scbw/bots/$BOTNAME/write"; cp it/sc-docker-support/BWAPI.dll "$HOME/.scbw/bots/$BOTNAME"; cp "$bot/target/"*-with-dependencies.jar "$HOME/.scbw/bots/$BOTNAME/AI"; cp "$bot/bot.json" "$HOME/.scbw/bots/$BOTNAME"; done
50+
scbw.play --headless --bots jbwapibot SittingDuck --timeout 180 --docker_image starcraft:game 2>&1 | grep 'Winner is BotPlayer:jbwapibot:T' || (cat $HOME/.scbw/games/*/logs_0/* && false)

.github/workflows/maven.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Java CI with Maven
5+
6+
on:
7+
- push
8+
- pull_request
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
java:
16+
- '8'
17+
- '11'
18+
#- '17'
19+
name: Java ${{ matrix.Java }} sample
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Setup java
23+
uses: actions/setup-java@v2
24+
with:
25+
distribution: 'temurin'
26+
java-version: ${{ matrix.java }}
27+
- name: Build with Maven
28+
run: mvn -B package --file pom.xml

.travis.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Also contains a modified version of the pure Java BWEM implementation from [BWAP
1616
- At least [5x](https://github.com/JavaBWAPI/JBWAPI/issues/17) faster compared to BWMirror for primitives as it directly reads the memory mapped client file. Even faster for BWAPI objects as it also avoids type marshalling
1717
- Supports both 32 and 64 bit Java (e.g. [deeplearning4j](https://deeplearning4j.org/) requires 64 bit Java which bwmirror doesn't support).
1818
- BWEM instead of BWTA as map analyser.
19+
- Supports Linux "natively" using [openbw](https://github.com/JavaBWAPI/JBWAPI/pull/73), made possible by by [ByteKeeper](https://github.com/Bytekeeper)
20+
- `Async` support for realtime tournament constraints, made possible by [dgant](https://github.com/dgant)
1921

2022
## Warnings
2123
- A fake BWTA is provided for easier porting from BWMirror, but it translates BWTA calls to their respective BWEM calls, so specific Regions/Chokepoints etc. may differ.
@@ -105,3 +107,17 @@ You can also ask any further questions on the [SSCAIT Discord](https://discord.g
105107
## Tutorial
106108

107109
If you are a just starting out with bot development, it might be helpful to follow the [tutorial](https://github.com/JavaBWAPI/Java-BWAPI-Tutorial/wiki)!
110+
111+
112+
## Bots
113+
114+
Some bots using [JBWAPI](https://github.com/JavaBWAPI/JBWAPI) (feel free to make add a `Pull Request` to add yours!)
115+
116+
- https://github.com/dgant/PurpleWave
117+
- https://github.com/Ravaelles/Atlantis
118+
- https://github.com/impie66/Kangaroo-Bot
119+
120+
## Linux
121+
122+
If you use Linux you can choose to develop normally and run the `jar` and `starcraft` using [wine](https://www.winehq.org/)`
123+
or try to use `openbw` by following the following [instructions](./build_with_openbw.md)

build_with_openbw.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Based on: #64
2+
3+
Compiling and running openbw on linux with client support:
4+
5+
```bash
6+
# Download build deps
7+
sudo apt install cmake libsdl2-dev libsdl2-mixer-dev #for ubuntu
8+
9+
# Build openbw with client support
10+
git clone https://github.com/basil-ladder/openbw
11+
git clone -b linux-client-support https://github.com/basil-ladder/bwapi
12+
cd bwapi
13+
mkdir build
14+
cd build
15+
cmake .. -DCMAKE_BUILD_TYPE=Release -DOPENBW_DIR=../../openbw -DOPENBW_ENABLE_UI=1
16+
make -j4
17+
18+
# Download runtime deps
19+
curl http://www.cs.mun.ca/~dchurchill/starcraftaicomp/files/Starcraft_1161.zip -o starcraft.zip
20+
unzip starcraft.zip patch_rt.mpq BROODAT.MPQ STARDAT.MPQ
21+
mv patch_rt.mpq Patch_rt.mpq && mv BROODAT.MPQ BrooDat.mpq && mv STARDAT.MPQ StarDat.mpq
22+
23+
# Run openbw using the map: Destination 1.1.scx
24+
unzip starcraft.zip "maps/BroodWar/ICCup/ICCup Destination 1.1.scx"
25+
26+
BWAPI_CONFIG_AUTO_MENU__RACE=Terran BWAPI_CONFIG_AUTO_MENU__MAP="maps/BroodWar/ICCup/ICCup Destination 1.1.scx" ./bin/BWAPILauncher
27+
```
28+
29+
Compiling and running openbw on macos with client support (not working):
30+
31+
```bash
32+
brew install cmake sdl2 sdl2_mixer gcc
33+
34+
cmake .. -D CMAKE_C_COMPILER=gcc-11 -D CMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Release -DOPENBW_DIR=../../openbw -DOPENBW_ENABLE_UI=1
35+
make -j4
36+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
import bwapi.BWClient;
12
import bwapi.DefaultBWListener;
23

34
public class SittingDuck extends DefaultBWListener {
5+
public static void main(String[] args) {
6+
new BWClient(new SittingDuck()).startGame();
7+
}
48
}

it/sc-docker-support/java.dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

pom.xml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<jmh.version>1.26</jmh.version>
13+
<jmh.version>1.33</jmh.version>
1414
</properties>
1515

1616
<build>
@@ -54,7 +54,7 @@
5454
<plugin>
5555
<groupId>org.apache.maven.plugins</groupId>
5656
<artifactId>maven-project-info-reports-plugin</artifactId>
57-
<version>3.1.1</version>
57+
<version>3.1.2</version>
5858
</plugin>
5959
<plugin>
6060
<groupId>org.apache.maven.plugins</groupId>
@@ -98,7 +98,7 @@
9898
<plugin>
9999
<groupId>org.apache.maven.plugins</groupId>
100100
<artifactId>maven-javadoc-plugin</artifactId>
101-
<version>3.2.0</version>
101+
<version>3.3.1</version>
102102
<configuration>
103103
<additionalOptions>-Xdoclint:none</additionalOptions>
104104
<additionalJOption>-Xdoclint:none</additionalJOption>
@@ -108,41 +108,52 @@
108108
</reporting>
109109

110110
<dependencies>
111+
<dependency>
112+
<groupId>no.fiken.oss.junixsocket</groupId>
113+
<artifactId>junixsocket-common</artifactId>
114+
<version>1.0.2</version>
115+
</dependency>
116+
<dependency>
117+
<groupId>no.fiken.oss.junixsocket</groupId>
118+
<artifactId>junixsocket-native-common</artifactId>
119+
<version>1.0.2</version>
120+
</dependency>
121+
111122
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
112123
<dependency>
113124
<groupId>net.java.dev.jna</groupId>
114125
<artifactId>jna</artifactId>
115-
<version>5.6.0</version>
126+
<version>5.10.0</version>
116127
</dependency>
117128

118129
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform -->
119130
<dependency>
120131
<groupId>net.java.dev.jna</groupId>
121132
<artifactId>jna-platform</artifactId>
122-
<version>5.6.0</version>
133+
<version>5.10.0</version>
123134
</dependency>
124135

125136
<!-- https://mvnrepository.com/artifact/junit/junit -->
126137
<dependency>
127138
<groupId>junit</groupId>
128139
<artifactId>junit</artifactId>
129-
<version>4.13.1</version>
140+
<version>4.13.2</version>
130141
<scope>test</scope>
131142
</dependency>
132143

133144
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
134145
<dependency>
135146
<groupId>org.mockito</groupId>
136147
<artifactId>mockito-core</artifactId>
137-
<version>3.5.15</version>
148+
<version>3.12.4</version>
138149
<scope>test</scope>
139150
</dependency>
140151

141152
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
142153
<dependency>
143154
<groupId>org.assertj</groupId>
144155
<artifactId>assertj-core</artifactId>
145-
<version>3.17.2</version>
156+
<version>3.21.0</version>
146157
<scope>test</scope>
147158
</dependency>
148159

src/main/java/bwapi/BWClient.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package bwapi;
22

3-
import com.sun.jna.platform.win32.Kernel32;
4-
53
import java.util.Objects;
64

75
/**

0 commit comments

Comments
 (0)