Skip to content

Commit

Permalink
Merge pull request #51 from Jabbo16/develop
Browse files Browse the repository at this point in the history
AIIDE 2020
  • Loading branch information
Jabbo16 committed Oct 1, 2020
2 parents 1ab9a15 + cb0f29f commit 4e6f844
Show file tree
Hide file tree
Showing 88 changed files with 6,121 additions and 253 deletions.
63 changes: 39 additions & 24 deletions build.gradle
@@ -1,35 +1,50 @@
apply plugin: 'java'
sourceCompatibility = 1.8
plugins {
id("java")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

sourceSets {
main {
java {
srcDir 'src'
}
}
java {
srcDir 'src'
}
}
}

repositories {
flatDir {
dirs 'lib'
}
mavenCentral()
maven { url 'https://jitpack.io' }
}

dependencies {
compile fileTree(dir: 'lib', include: ['*.jar'], exclude: ['*-javadoc.jar'])
implementation('com.google.code.gson:gson:2.8.6')
implementation('com.github.luben:zstd-jni:1.4.4-4:win_x86')
implementation('javazoom:jlayer:1.0.1')
implementation('com.github.Bytekeeper:ass:1.1')
}

task copyConfig(type: Copy) {
from file("config.json")
into file("build/libs/")
}

task fatJar(type: Jar) {
baseName = 'Ecgberht'
from('src/') {
include '*.mp3'
tasks {
task copyConfig(type: Copy) {
from file("config.json")
into file("build/libs/")
}
manifest {
attributes 'Main-Class': 'ecgberht.Ecgberht'

task fatJar(type: Jar) {
archiveBaseName = 'Ecgberht'
from('src/') {
include '*.mp3'
}
manifest {
attributes 'Main-Class': 'ecgberht.Ecgberht'
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
fatJar.dependsOn copyConfig
fatJar.dependsOn copyConfig
}
5 changes: 4 additions & 1 deletion config.json
Expand Up @@ -13,6 +13,9 @@
"sounds": false,
"sscait": false,
"enableSkyCladObserver": false,
"forceStrat": ""
"forceStrat": "",
"enableCherryVisDump": false,
"debugDisableAttack": false,
"humanMode": false
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Binary file modified lib/BWAPI4J.jar
Binary file not shown.
Binary file removed lib/ass-1.1.jar
Binary file not shown.
Binary file removed lib/gson-2.8.5-javadoc.jar
Binary file not shown.
Binary file removed lib/gson-2.8.5.jar
Binary file not shown.
Binary file removed lib/jl1.0.1.jar
Binary file not shown.
65 changes: 65 additions & 0 deletions src/bwem/Altitude.java
@@ -0,0 +1,65 @@
// Original work Copyright (c) 2015, 2017, Igor Dimitrijevic
// Modified work Copyright (c) 2017-2018 OpenBW Team

//////////////////////////////////////////////////////////////////////////
//
// This file is part of the BWEM Library.
// BWEM is free software, licensed under the MIT/X11 License.
// A copy of the license is provided with the library in the LICENSE file.
// Copyright (c) 2015, 2017, Igor Dimitrijevic
//
//////////////////////////////////////////////////////////////////////////

package bwem;

import bwem.util.Pair;

import java.util.Comparator;

/**
* Immutable wrapper of the integer primitive to satisfy the original C++ definition:
* defs.h:54:typedef int16_t altitude_t;
*
* <p>Type of the altitudes in pixels.
*/
public final class Altitude implements Comparable<Altitude> {
public static final Altitude UNINITIALIZED = new Altitude(-1);
public static final Altitude ZERO = new Altitude(0);
public static final Comparator<Pair<?, Altitude>> BY_ALTITUDE_ORDER = Comparator.comparing(p -> p.getRight().intValue());
private final int val;

Altitude(final int val) {
this.val = val;
}

public int intValue() {
return this.val;
}

@Override
public int compareTo(final Altitude that) {
return Integer.compare(this.val, that.val);
}

@Override
public boolean equals(final Object object) {
if (this == object) {
return true;
} else if (!(object instanceof Altitude)) {
return false;
} else {
final Altitude that = (Altitude) object;
return (this.val == that.val);
}
}

@Override
public int hashCode() {
return this.val;
}

@Override
public String toString() {
return String.valueOf(this.val);
}
}
154 changes: 154 additions & 0 deletions src/bwem/Area.java
@@ -0,0 +1,154 @@
// Original work Copyright (c) 2015, 2017, Igor Dimitrijevic
// Modified work Copyright (c) 2017-2018 OpenBW Team

//////////////////////////////////////////////////////////////////////////
//
// This file is part of the BWEM Library.
// BWEM is free software, licensed under the MIT/X11 License.
// A copy of the license is provided with the library in the LICENSE file.
// Copyright (c) 2015, 2017, Igor Dimitrijevic
//
//////////////////////////////////////////////////////////////////////////

package bwem;

import org.openbw.bwapi4j.TilePosition;
import org.openbw.bwapi4j.WalkPosition;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public abstract class Area {
final java.util.Map<Area, List<ChokePoint>> chokePointsByArea = new HashMap<>();
final List<Area> accessibleNeighbors = new ArrayList<>();
final List<ChokePoint> chokePoints = new ArrayList<>();
final List<Mineral> minerals = new ArrayList<>();
final List<Geyser> geysers = new ArrayList<>();
final List<Base> bases = new ArrayList<>();
private final AreaId id;
private final WalkPosition walkPositionWithHighestAltitude;
private final int miniTileCount;
int groupId = 0;
Altitude highestAltitude;
TilePosition topLeft = new TilePosition(Integer.MAX_VALUE, Integer.MAX_VALUE);
TilePosition bottomRight = new TilePosition(Integer.MIN_VALUE, Integer.MIN_VALUE);
int tileCount = 0;
int buildableTileCount =
0; /* Set and later incremented but not used in original C++ BWEM 1.4.1. Remains for portability consistency. */
int highGroundTileCount = 0;
int veryHighGroundTileCount = 0;

protected final BWMap map;


Area(final AreaId areaId, final WalkPosition top, final int miniTileCount, final BWMap map) {
this.id = areaId;
this.walkPositionWithHighestAltitude = top;
this.miniTileCount = miniTileCount;
this.map = map;
}

public AreaId getId() {
return this.id;
}

public int getGroupId() {
return this.groupId;
}

public TilePosition getTopLeft() {
return this.topLeft;
}

public TilePosition getBottomRight() {
return this.bottomRight;
}

public TilePosition getBoundingBoxSize() {
return this.bottomRight.subtract(this.topLeft).add(new TilePosition(1, 1));
}

public WalkPosition getWalkPositionWithHighestAltitude() {
return this.walkPositionWithHighestAltitude;
}

public WalkPosition getTop() {
return getWalkPositionWithHighestAltitude();
}

public Altitude getHighestAltitude() {
return this.highestAltitude;
}

public int getSize() {
return this.miniTileCount;
}

public int getLowGroundPercentage() {
final int lowGroundTileCount =
this.tileCount - this.highGroundTileCount - this.veryHighGroundTileCount;
return ((lowGroundTileCount * 100) / this.tileCount);
}

public int getHighGroundPercentage() {
return ((this.highGroundTileCount * 100) / this.tileCount);
}

public int getVeryHighGroundPercentage() {
return ((this.veryHighGroundTileCount * 100) / tileCount);
}

public List<ChokePoint> getChokePoints() {
return this.chokePoints;
}

public List<ChokePoint> getChokePoints(final Area area) {
final List<ChokePoint> ret = this.chokePointsByArea.get(area);
if (ret == null) {
map.asserter.throwIllegalStateException("");
}
return ret;
}

public java.util.Map<Area, List<ChokePoint>> getChokePointsByArea() {
return this.chokePointsByArea;
}

public List<Area> getAccessibleNeighbors() {
return this.accessibleNeighbors;
}

public boolean isAccessibleFrom(final Area area) {
return groupId == area.getGroupId();
}

public List<Mineral> getMinerals() {
return this.minerals;
}

public List<Geyser> getGeysers() {
return this.geysers;
}

public List<Base> getBases() {
return this.bases;
}

@Override
public boolean equals(final Object object) {
if (this == object) {
return true;
} else if (!(object instanceof Area)) {
return false;
} else {
final Area that = (Area) object;
return (getId().equals(that.getId()));
}
}

@Override
public int hashCode() {
return getId().hashCode();
}
}
53 changes: 53 additions & 0 deletions src/bwem/AreaId.java
@@ -0,0 +1,53 @@
// Original work Copyright (c) 2015, 2017, Igor Dimitrijevic
// Modified work Copyright (c) 2017-2018 OpenBW Team

//////////////////////////////////////////////////////////////////////////
//
// This file is part of the BWEM Library.
// BWEM is free software, licensed under the MIT/X11 License.
// A copy of the license is provided with the library in the LICENSE file.
// Copyright (c) 2015, 2017, Igor Dimitrijevic
//
//////////////////////////////////////////////////////////////////////////

package bwem;

/**
* Immutable wrapper of the integer primitive to satisfy the original C++ definition:
* area.h:54:typedef int16_t id;
*/
public final class AreaId implements Comparable<AreaId> {
public static final AreaId UNINITIALIZED = new AreaId(-1);
public static final AreaId ZERO = new AreaId(0);
private final int val;

AreaId(final int val) {
this.val = val;
}

public int intValue() {
return this.val;
}

@Override
public int compareTo(final AreaId that) {
return Integer.compare(this.val, that.val);
}

@Override
public boolean equals(final Object object) {
if (this == object) {
return true;
} else if (!(object instanceof AreaId)) {
return false;
} else {
final AreaId that = (AreaId) object;
return (this.val == that.val);
}
}

@Override
public int hashCode() {
return this.val;
}
}

0 comments on commit 4e6f844

Please sign in to comment.