Skip to content

Commit 1233d4f

Browse files
authored
Merge pull request #42 from JavaBWAPI/newlatcom
Implement LatCom
2 parents 7cdfd09 + 0ada566 commit 1233d4f

File tree

9 files changed

+1184
-32
lines changed

9 files changed

+1184
-32
lines changed

README.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
[![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)
22
# JBWAPI
3+
34
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).
45

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

7-
## goals
8+
## Goals
9+
810
- Have a similar (Java) interface to BWMirror to make porting BWMirror bots easy without all the DLL and JNI hassle and overhead.
9-
- Stay as updated as possible with the BWAPI releases
11+
- Stay as updated as possible with the BWAPI releases.
12+
13+
## Advantages
1014

11-
## advantages
12-
- no dependency on external DLL's
13-
- 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
14-
- supports both 32 and 64 bit Java (e.g. [deeplearning4j](https://deeplearning4j.org/) requires 64 bit Java which bwmirror doesn't support)
15-
- BWEM instead of BWTA as map analyser
15+
- No dependency on external DLL's.
16+
- 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
17+
- Supports both 32 and 64 bit Java (e.g. [deeplearning4j](https://deeplearning4j.org/) requires 64 bit Java which bwmirror doesn't support).
18+
- BWEM instead of BWTA as map analyser.
1619

17-
## warnings
18-
- JBWAPI by default has Lateny Compensation disabled (and at the moment has no LatCom at all).
19-
- 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.
20+
## Warnings
21+
- 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.
2022

21-
## usage
22-
**maven**
23+
## Usage
2324

24-
Add JitPack as a repository
25+
**Maven**
26+
27+
Add JitPack as a repository:
2528
```
2629
<repositories>
2730
<repository>
@@ -30,7 +33,7 @@ Add JitPack as a repository
3033
</repository>
3134
</repositories>
3235
```
33-
Add JBWAPI as a dependecy
36+
Add JBWAPI as a dependency:
3437
```
3538
<dependency>
3639
<groupId>com.github.JavaBWAPI</groupId>
@@ -39,9 +42,9 @@ Add JBWAPI as a dependecy
3942
</dependency>
4043
```
4144

42-
**gradle**
45+
**Gradle**
4346

44-
Add JitPack as a repository
47+
Add JitPack as a repository:
4548
```
4649
allprojects {
4750
repositories {
@@ -50,31 +53,31 @@ allprojects {
5053
}
5154
}
5255
```
53-
Add JBWAPI as a dependency
56+
Add JBWAPI as a dependency:
5457
```
5558
dependencies {
5659
implementation 'com.github.JavaBWAPI:JBWAPI:0.8'
5760
}
5861
```
5962

60-
**jar**
63+
**Jar**
6164

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

64-
## compilation
67+
## Compilation
68+
6569
`mvnw.cmd package`
6670

6771
or if you already have maven installed
6872

6973
`mvn package`
7074

71-
## documentation
75+
## Documentation
7276

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

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

77-
## tutorial
81+
## Tutorial
7882

7983
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)!
80-

src/main/java/bwapi/Cache.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package bwapi;
2+
3+
4+
class Cache<T> {
5+
private int frame = -1;
6+
private T obj;
7+
8+
void set(T obj, int frame) {
9+
this.frame = frame;
10+
this.obj = obj;
11+
}
12+
13+
boolean valid(int currentFrame) {
14+
return frame == currentFrame;
15+
}
16+
17+
T get() {
18+
return obj;
19+
}
20+
}
21+
22+
class IntegerCache extends Cache<Integer> {
23+
24+
void setOrAdd(int obj, int frame) {
25+
if (valid(frame)) {
26+
set(get() + obj, frame);
27+
}
28+
else {
29+
set(obj, frame);
30+
}
31+
}
32+
}
33+
34+
class BooleanCache extends Cache<Boolean>{}
35+
class OrderCache extends Cache<Order>{}
36+
class UnitTypeCache extends Cache<UnitType>{}
37+
class UpgradeTypeCache extends Cache<UpgradeType>{}
38+
class TechTypeCache extends Cache<TechType>{}

0 commit comments

Comments
 (0)