Skip to content

Commit 29c4e67

Browse files
committed
Add BWTA warning & more set->list
1 parent 58b7786 commit 29c4e67

File tree

4 files changed

+34
-31
lines changed

4 files changed

+34
-31
lines changed

src/main/java/bwta/BWTA.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ public class BWTA {
1717
static Map<Area, Region> regionMap;
1818
static Map<ChokePoint, Chokepoint> chokeMap;
1919
static Map<Base, BaseLocation> baseMap;
20-
private static Set<Region> regions;
21-
private static Set<Chokepoint> chokepoints;
22-
private static Set<BaseLocation> baseLocations;
20+
private static List<Region> regions;
21+
private static List<Chokepoint> chokepoints;
22+
private static List<BaseLocation> baseLocations;
2323

2424
public static void readMap(final Game game) {
25+
System.err.println("WARNING: this BWTA is fake and only translates BWTA calls to their respective BWEM calls. Please use BWEM directly if possible.");
2526
bwem = new BWEM(game);
2627
}
2728

@@ -32,37 +33,37 @@ public static void analyze() {
3233
for (final Area a : bwem.getMap().getAreas()) {
3334
regionMap.put(a, new Region(a));
3435
}
35-
regions = new HashSet<>(regionMap.values());
36+
regions = new ArrayList<>(regionMap.values());
3637

3738
chokeMap = new HashMap<>();
3839
for (final ChokePoint c : bwem.getMap().getChokePoints()) {
3940
chokeMap.put(c, new Chokepoint(c));
4041
}
41-
chokepoints = new HashSet<>(chokeMap.values());
42+
chokepoints = new ArrayList<>(chokeMap.values());
4243

4344
baseMap = new HashMap<>();
4445
for (final Base b : bwem.getMap().getBases()) {
4546
baseMap.put(b, new BaseLocation(b));
4647
}
47-
baseLocations = new HashSet<>(baseMap.values());
48+
baseLocations = new ArrayList<>(baseMap.values());
4849
}
4950

50-
public static Set<Region> getRegions() {
51-
return regions;
51+
public static List<Region> getRegions() {
52+
return new ArrayList<>(regions);
5253
}
5354

54-
public static Set<Chokepoint> getChokepoints() {
55-
return chokepoints;
55+
public static List<Chokepoint> getChokepoints() {
56+
return new ArrayList<>(chokepoints);
5657
}
5758

58-
public static Set<BaseLocation> getBaseLocations() {
59-
return baseLocations;
59+
public static List<BaseLocation> getBaseLocations() {
60+
return new ArrayList<>(baseLocations);
6061
}
6162

62-
public static Set<BaseLocation> getStartLocations() {
63+
public static List<BaseLocation> getStartLocations() {
6364
return getBaseLocations().stream()
6465
.filter(BaseLocation::isStartLocation)
65-
.collect(Collectors.toSet());
66+
.collect(Collectors.toList());
6667
}
6768

6869
public static BaseLocation getStartLocation(final Player player) {

src/main/java/bwta/BaseLocation.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import bwapi.Unit;
66
import bwem.Base;
77

8+
import java.util.ArrayList;
9+
import java.util.List;
810
import java.util.Set;
911
import java.util.stream.Collectors;
1012

@@ -14,8 +16,8 @@ public class BaseLocation {
1416
private final TilePosition tilePosition;
1517
private final int minerals;
1618
private final int gas;
17-
private final Set<Unit> mineralSet;
18-
private final Set<Unit> geyserSet;
19+
private final List<Unit> mineralSet;
20+
private final List<Unit> geyserSet;
1921
private final boolean island;
2022
private final boolean mineralOnly;
2123
private final boolean startLocation;
@@ -27,8 +29,8 @@ public class BaseLocation {
2729
this.tilePosition = base.getLocation();
2830
this.minerals = 1;
2931
this.gas = 1;
30-
this.mineralSet = base.getMinerals().stream().map(m -> m.getUnit()).collect(Collectors.toSet());
31-
this.geyserSet = base.getGeysers().stream().map(g -> g.getUnit()).collect(Collectors.toSet());
32+
this.mineralSet = base.getMinerals().stream().map(m -> m.getUnit()).collect(Collectors.toList());
33+
this.geyserSet = base.getGeysers().stream().map(g -> g.getUnit()).collect(Collectors.toList());
3234
this.island = base.getArea().getAccessibleNeighbors().isEmpty();
3335
this.mineralOnly = !mineralSet.isEmpty() && geyserSet.isEmpty();
3436
this.startLocation = base.isStartingLocation();
@@ -54,12 +56,12 @@ public int gas() {
5456
return gas;
5557
}
5658

57-
public Set<Unit> getMinerals() {
58-
return mineralSet;
59+
public List<Unit> getMinerals() {
60+
return new ArrayList<>(mineralSet);
5961
}
6062

61-
public Set<Unit> getGeysers() {
62-
return geyserSet;
63+
public List<Unit> getGeysers() {
64+
return new ArrayList<>(geyserSet);
6365
}
6466

6567
public double getGroundDistance(final BaseLocation other) {

src/main/java/bwta/Chokepoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010

1111
public class Chokepoint {
12-
private ChokePoint chokePoint;
13-
private Pair<Position, Position> sides;
12+
private ChokePoint chokePoint;
13+
private Pair<Position, Position> sides;
1414
private Position center;
1515
private double width;
1616

src/main/java/bwta/Region.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import bwapi.Position;
44
import bwem.area.Area;
55

6+
import java.util.List;
67
import java.util.Set;
78
import java.util.stream.Collectors;
89

@@ -15,31 +16,30 @@ public class Region {
1516
this.center = area.getWalkPositionWithHighestAltitude().toPosition();
1617
}
1718

18-
1919
public Position getCenter() {
2020
return center;
2121
}
2222

23-
public Set<Chokepoint> getChokepoints() {
23+
public List<Chokepoint> getChokepoints() {
2424
return area.getChokePoints().stream()
2525
.map(c -> BWTA.chokeMap.get(c))
26-
.collect(Collectors.toSet());
26+
.collect(Collectors.toList());
2727
}
2828

29-
public Set<BaseLocation> getBaseLocations() {
29+
public List<BaseLocation> getBaseLocations() {
3030
return area.getBases().stream()
3131
.map(b -> BWTA.baseMap.get(b))
32-
.collect(Collectors.toSet());
32+
.collect(Collectors.toList());
3333
}
3434

3535
public boolean isReachable(final Region region) {
3636
return area.isAccessibleFrom(region.area);
3737
}
3838

39-
public Set<Region> getReachableRegions() {
39+
public List<Region> getReachableRegions() {
4040
return area.getAccessibleNeighbors().stream()
4141
.map(a -> BWTA.regionMap.get(a))
42-
.collect(Collectors.toSet());
42+
.collect(Collectors.toList());
4343
}
4444

4545
@Override

0 commit comments

Comments
 (0)