Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
f86f766
Update README.md
May 11, 2019
e0de0c8
Don't fail if the cache file doesn't exist.
May 11, 2019
7eb1439
Update README.md
JasperGeurtz Jun 16, 2019
fa47f62
Don't cache unittype & player anymore, using Unsafe makes this much f…
JasperGeurtz Jun 21, 2019
aa936a5
Use autogenerated equals & make enums more consistent
JasperGeurtz Aug 5, 2019
eefd1de
fix wrong brackets in buildingPlacer code
JasperGeurtz Aug 6, 2019
3c6b1f5
increment version
JasperGeurtz Aug 6, 2019
fdaed5a
string fix and equals fix
JasperGeurtz Aug 6, 2019
c4f0970
getClosestUnitInRadius -> getClosestUnit to be consistent with Game.h
JasperGeurtz Aug 7, 2019
5f31852
fix typo in TechTYpe::whatUses
JasperGeurtz Aug 7, 2019
1e14606
Make some classes comparable
JasperGeurtz Aug 7, 2019
b9eafa5
Add bwapi filters
JasperGeurtz Aug 7, 2019
9acf835
add documentation dumper
JasperGeurtz Aug 7, 2019
a3e3f09
dump documentation
JasperGeurtz Aug 7, 2019
ad32c2b
add maven plugin stuff
JasperGeurtz Aug 7, 2019
60193aa
add documentation link
JasperGeurtz Aug 7, 2019
e3f8446
some manual fixes
JasperGeurtz Aug 7, 2019
bc54ecd
more manual fixes
JasperGeurtz Aug 7, 2019
f4404ff
fill arrays with missing 0's
JasperGeurtz Aug 9, 2019
7c74271
increment version number
JasperGeurtz Aug 9, 2019
c654747
Added a unit test for string put/get. (And changed the implementation…
Aug 10, 2019
0d4ac23
Added unit tests for BWAPI types to verify parameter-less getters can…
Aug 10, 2019
3b381d4
Added micro benchmarking using JMH
Aug 10, 2019
9104aae
ISO-8859-1 is mapped to Unicode blocks 0 and 1 and no re-encoding sho…
Aug 10, 2019
cac744f
Added reference benchmark to "compare" different runs
Aug 10, 2019
fdc3868
Added reference benchmark to "compare" different runs
Aug 10, 2019
734634c
Merge pull request #39 from JavaBWAPI/fasterGetPutString
JasperGeurtz Aug 11, 2019
a066ea9
directly init closestColor
JasperGeurtz Aug 14, 2019
ad4fdff
use predicate for filters and put them in the UnitFilter 'namespace'
JasperGeurtz Aug 14, 2019
67398b1
Merge branch 'develop' into filters
JasperGeurtz Aug 14, 2019
b3d8eb7
Merge pull request #36 from JavaBWAPI/filters
Aug 14, 2019
5c2212d
merge develop
JasperGeurtz Aug 15, 2019
74447ef
merge develop
JasperGeurtz Aug 15, 2019
c46e0ee
fix Bullet javadoc
JasperGeurtz Aug 15, 2019
3ab7d65
Small documentation additions
JasperGeurtz Aug 15, 2019
9e1eb38
Naming fixes for documentation and method names
JasperGeurtz Aug 15, 2019
62a20f0
Fix force & flag & explosiontype javadoc
JasperGeurtz Aug 15, 2019
f4a5248
Fix Game javadoc and some potential OOB issues
JasperGeurtz Aug 15, 2019
9a550b4
Add unit javadoc and re-add canUseTech(TechType tech) method
JasperGeurtz Aug 17, 2019
e2c74d9
Fix some enums documentation
JasperGeurtz Aug 17, 2019
67bc4d4
Player(Type) doc fixes
JasperGeurtz Aug 17, 2019
432430e
Finish documentation for the remaining classes
JasperGeurtz Aug 29, 2019
bb522cf
Small issueCommand optimisation
JasperGeurtz Aug 29, 2019
62d475e
Fixed @see warnings
Aug 30, 2019
d374fba
Merge pull request #37 from JavaBWAPI/documentation
Bytekeeper Aug 30, 2019
38bbc97
Update dependency versions & add reporting via mvn site
JasperGeurtz Aug 31, 2019
226b97a
pull develop
JasperGeurtz Aug 31, 2019
9f57210
Make benchmark run on Windows
JasperGeurtz Aug 31, 2019
b6ebda5
update version number
JasperGeurtz Aug 31, 2019
e0b549d
revert Windows only working change
JasperGeurtz Aug 31, 2019
b520a06
more @see fixes
JasperGeurtz Aug 31, 2019
9d224fb
Add sscait discord link to readme
JasperGeurtz Aug 31, 2019
881b5d8
remove wildcard argument for benchmark
JasperGeurtz Sep 3, 2019
9a3b04b
Merge branch 'develop' of https://github.com/JavaBWAPI/JBWAPI into de…
JasperGeurtz Sep 3, 2019
56d3d5c
Added approx distance to Position too, since bots can't access Point.
Sep 16, 2019
003c4b7
update version to 0.8.1
JasperGeurtz Sep 17, 2019
7ce225b
fix neutralunits not getting added as neutral is not yet initialised,…
JasperGeurtz Sep 18, 2019
3827fb1
update version number
JasperGeurtz Sep 18, 2019
efb8534
Make Point and its subclasses more consistent
JasperGeurtz Sep 27, 2019
1b9fce9
implement missing commented out methods
JasperGeurtz Sep 27, 2019
0972118
fix some bugs in Game & remove /p from docs
JasperGeurtz Sep 28, 2019
b3855c0
intelliJ cleanup
JasperGeurtz Sep 28, 2019
8f6c162
rename TextColor to Text to adhere to BWAPI
JasperGeurtz Sep 28, 2019
616f125
make TextSize part of Text as Size to adhere to BWAPI structure
JasperGeurtz Sep 28, 2019
685adb1
This fixes issue with loading terran units into bunker.
Sep 29, 2019
f1648a6
Improved .gitignore to not track eclipse IDE files.
Sep 29, 2019
c200b55
Merge pull request #40 from petrholik/feature/bunker-fix
JasperGeurtz Sep 29, 2019
7567bae
add latcom
JasperGeurtz Sep 29, 2019
5862bc4
remove debug function
JasperGeurtz Sep 29, 2019
d1a6767
nullcheck fixes
JasperGeurtz Sep 29, 2019
97eee51
more nullguards, shouldn't happen but doesn't harm either
JasperGeurtz Sep 29, 2019
deab9e5
format code
JasperGeurtz Sep 29, 2019
7ea1139
apply energy difference
JasperGeurtz Sep 30, 2019
8f539bb
same for hitpoints
JasperGeurtz Sep 30, 2019
dc06343
fix hitpoint
JasperGeurtz Sep 30, 2019
a898945
energy should be setOrAdd, thanks @noobyedge
JasperGeurtz Sep 30, 2019
61cc103
Merge pull request #43 from JavaBWAPI/text
JasperGeurtz Sep 30, 2019
8b84fed
fixes
JasperGeurtz Oct 1, 2019
f7d9963
Merge remote-tracking branch 'origin' into newlatcom
JasperGeurtz Oct 1, 2019
6909bf6
merge develop
JasperGeurtz Oct 1, 2019
c924c9a
Better readme
Jabbo16 Oct 1, 2019
0faea26
Merge pull request #44 from Jabbo16/patch-1
JasperGeurtz Oct 1, 2019
0ada566
Update README.md
JasperGeurtz Oct 1, 2019
70b9f9c
Added package declaration.
Sep 29, 2019
7cdfd09
Merge pull request #41 from petrholik/feature/polishing
JasperGeurtz Oct 1, 2019
19b9cd9
bwem fixes for sparkle and neoaztec
JasperGeurtz Oct 5, 2019
1233d4f
Merge pull request #42 from JavaBWAPI/newlatcom
JasperGeurtz Oct 5, 2019
49934b3
bwem cleanup
JasperGeurtz Oct 5, 2019
59d0ef4
use cast for unit
JasperGeurtz Oct 5, 2019
3d2fc34
Add setting to BWEM to continue analysing even if there is an invalid…
JasperGeurtz Oct 20, 2019
12a3308
add docu + small fixes
JasperGeurtz Oct 20, 2019
c6fd7e1
remove map testing class
JasperGeurtz Oct 20, 2019
fe411b4
Merge branch 'bwem-fixes' into develop
JasperGeurtz Oct 20, 2019
a4af17c
update to version v1.0
JasperGeurtz Oct 20, 2019
87d5694
update dependency
JasperGeurtz Oct 20, 2019
5b3a5fa
Update README.md
JasperGeurtz Oct 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ target/
#intellij
.idea/
*.iml
.settings
.classpath
.project

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ before_script:
- pushd sc-docker
- python3 setup.py bdist_wheel
- pip3 install dist/scbw*.whl
- '[ -f /tmp/sc-docker/starcraft.zip ] && (cp /tmp/sc-docker/starcraft.zip scbw/local_docker && echo "Using cached starcraft.zip")'
- '[ ! -f /tmp/sc-docker/starcraft.zip ] || (cp /tmp/sc-docker/starcraft.zip scbw/local_docker && echo "Using cached starcraft.zip")'
- cd docker
- ./build_images.sh
- popd
Expand Down
57 changes: 33 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
[![Build Status](https://travis-ci.org/JavaBWAPI/JBWAPI.svg?branch=develop)](https://travis-ci.org/JavaBWAPI/JBWAPI)[![Total alerts](https://img.shields.io/lgtm/alerts/g/JavaBWAPI/JBWAPI.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/JavaBWAPI/JBWAPI/alerts/)[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/JavaBWAPI/JBWAPI.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/JavaBWAPI/JBWAPI/context:java)
# JBWAPI

Pure Java [bwapi](https://github.com/bwapi/bwapi) 4.4.0 client implementation backed by [N00byEdge](https://github.com/N00byEdge)'s [JavaBWAPIBackend](https://github.com/N00byEdge/JavaBWAPIBackend) idea and automated by [Bytekeeper](https://github.com/Bytekeeper).

Also contains the pure Java BWEM implementation from [BWAPI4J](https://github.com/OpenBW/BWAPI4J).
Also contains a modified version of the pure Java BWEM implementation from [BWAPI4J](https://github.com/OpenBW/BWAPI4J).

## Goals

## goals
- Have a similar (Java) interface to BWMirror to make porting BWMirror bots easy without all the DLL and JNI hassle and overhead.
- Stay as updated as possible with the BWAPI releases
- Stay as updated as possible with the BWAPI releases.

## Advantages

- No dependency on external DLL's.
- 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
- Supports both 32 and 64 bit Java (e.g. [deeplearning4j](https://deeplearning4j.org/) requires 64 bit Java which bwmirror doesn't support).
- BWEM instead of BWTA as map analyser.

## advantages
- no dependency on external DLL's
- no type marshalling
- fast (citation needed)
- supports both 32 and 64 bit Java (e.g. [deeplearning4j](https://deeplearning4j.org/) requires 64 bit Java which bwmirror doesn't support)
- BWEM instead of BWTA as map analyser
## Warnings
- 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.

## warnings
- JBWAPI by default has Lateny Compensation disabled (and at the moment has no LatCom at all).
- A fake BWTA is provided for easier porting, but it translates BWTA calls to their respective BWEM calls, so specific Regions/Chokepoints etc. may differ.
## Usage

## usage
**maven**
**Maven**

Add JitPack as a repository
Add JitPack as a repository:
```
<repositories>
<repository>
Expand All @@ -31,18 +33,18 @@ Add JitPack as a repository
</repository>
</repositories>
```
Add JBWAPI as a dependecy
Add JBWAPI as a dependency:
```
<dependency>
<groupId>com.github.JavaBWAPI</groupId>
<artifactId>JBWAPI</artifactId>
<version>0.7</version>
<version>1.0.0</version>
</dependency>
```

**gradle**
**Gradle**

Add JitPack as a repository
Add JitPack as a repository:
```
allprojects {
repositories {
Expand All @@ -51,24 +53,31 @@ allprojects {
}
}
```
Add JBWAPI as a dependecy
Add JBWAPI as a dependency:
```
dependencies {
implementation 'com.github.JavaBWAPI:JBWAPI:0.7'
implementation 'com.github.JavaBWAPI:JBWAPI:1.0.0'
}
```

**jar**
**Jar**

Alternatively add the latest .jar from the [releases](https://github.com/JavaBWAPI/JBWAPI/releases) page to your project.

## compilation
## Compilation

`mvnw.cmd package`

or if you already have maven installed

`mvn package`

## tutorial
## Documentation

The API documentation can be found [here](https://javabwapi.github.io/JBWAPI/).

You can also ask any further questions on the [SSCAIT Discord](https://discord.gg/DqvHsq9)

## Tutorial

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)!
2 changes: 1 addition & 1 deletion it/bots/SittingDuck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>jbwapi.it</groupId>
<artifactId>bots</artifactId>
<version>0.7</version>
<version>1.0.0</version>
</parent>

<artifactId>SittingDuck</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions it/bots/jbwapibot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>jbwapi.it</groupId>
<artifactId>bots</artifactId>
<version>0.7</version>
<version>1.0.0</version>
</parent>

<artifactId>MarineHell</artifactId>
Expand All @@ -26,7 +26,7 @@
<configuration>
<archive>
<manifest>
<mainClass>MarineHell</mainClass>
<mainClass>marinehell.MarineHell</mainClass>
</manifest>
</archive>
<descriptorRefs>
Expand Down
4 changes: 2 additions & 2 deletions it/bots/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>jbwapi.it</groupId>
<artifactId>bots</artifactId>
<version>0.7</version>
<version>1.0.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>jbwapi</groupId>
<artifactId>jbwapi</artifactId>
<version>0.7</version>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
77 changes: 70 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@

<groupId>jbwapi</groupId>
<artifactId>jbwapi</artifactId>
<version>0.7</version>
<version>1.0.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.21</jmh.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
Expand All @@ -30,7 +31,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
Expand All @@ -45,22 +46,69 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>run-benchmarks</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.openjdk.jmh.Main</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<additionalOptions>-Xdoclint:none</additionalOptions>
<additionalJOption>-Xdoclint:none</additionalJOption>
</configuration>
</plugin>
</plugins>
</reporting>

<dependencies>
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.2.0</version>
<version>5.4.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.2.0</version>
<version>5.4.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/junit/junit -->
Expand All @@ -75,15 +123,30 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.26.0</version>
<version>3.1.0</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.12.2</version>
<version>3.13.2</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.openjdk.jmh -->
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/bwapi/BWClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.util.Objects;

/**
* Client class to connect to the game with.
*/
public class BWClient {
private final BWEventListener eventListener;

Expand All @@ -14,10 +17,16 @@ public BWClient(final BWEventListener eventListener) {
this.eventListener = eventListener;
}

/**
* Get the {@link Game} instance of the currently running game.
*/
public Game getGame() {
return handler == null ? null : handler.getGame();
}

/**
* Start the game.
*/
public void startGame() {
while (client == null) {
try {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/bwapi/BWEventListener.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package bwapi;


/**
* Interface to extend to be given to a {@link BWClient}.
*/
public interface BWEventListener {

void onStart();
Expand Down
Loading