Skip to content

Commit 20c803d

Browse files
JasperGeurtzBytekeeper
authored andcommitted
prefer BWMap over BWEMMap
1 parent 0ce2f0d commit 20c803d

20 files changed

+77
-59
lines changed

src/main/java/bwapi/Game.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ public boolean canBuildHere(final TilePosition position, final UnitType type, fi
679679
position;
680680
final TilePosition rb = lt.add(type.tileSize());
681681

682-
// BWEMMap limit check
682+
// Map limit check
683683
if (!lt.isValid(this) || !(rb.toPosition().subtract(new Position(1, 1)).isValid(this))) {
684684
return false;
685685
}

src/main/java/bwem/AreaInitializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ class AreaInitializer extends Area {
3030
private static final StaticMarkable staticMarkable = new StaticMarkable();
3131
private final Markable markable;
3232

33-
private final BWEMMap map;
33+
private final BWMap map;
3434

3535
AreaInitializer(
36-
final BWEMMap map, final AreaId areaId, final WalkPosition top, final int miniTileCount) {
36+
final BWMap map, final AreaId areaId, final WalkPosition top, final int miniTileCount) {
3737
super(areaId, top, miniTileCount);
3838

3939
this.map = map;

src/main/java/bwem/BWEM.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
import bwapi.Game;
1616

1717
public final class BWEM {
18-
private final BWEMMap map;
18+
private final BWMap map;
1919

2020
public BWEM(final Game game) {
21-
this.map = new BWEMMapInitializer(game);
21+
this.map = new BWMapInitializer(game);
2222
}
2323

2424
/**
2525
* Returns the root internal data container.
2626
*/
27-
public BWEMMap getMap() {
27+
public BWMap getMap() {
2828
return this.map;
2929
}
3030

@@ -33,10 +33,10 @@ public BWEMMap getMap() {
3333
* Initializes and pre-computes all of the internal data.
3434
*/
3535
public void initialize() {
36-
if (!(this.map instanceof BWEMMapInitializer)) {
36+
if (!(this.map instanceof BWMapInitializer)) {
3737
throw new IllegalStateException("BWEM was not instantiated properly.");
3838
}
39-
((BWEMMapInitializer) this.map).initialize();
39+
((BWMapInitializer) this.map).initialize();
4040
this.map.assignStartingLocationsToSuitableBases();
4141
}
4242
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import static bwem.AreaId.UNINITIALIZED;
2424

25-
public abstract class BWEMMap {
25+
public abstract class BWMap {
2626

2727
final List<Pair<Pair<AreaId, AreaId>, WalkPosition>> rawFrontier =
2828
new ArrayList<>();
@@ -38,7 +38,7 @@ public abstract class BWEMMap {
3838
NeutralData neutralData = null;
3939
Altitude highestAltitude;
4040

41-
BWEMMap(final Game game) {
41+
BWMap(final Game game) {
4242
this.game = game;
4343
this.players = game.getPlayers();
4444
this.mineralPatches = game.getMinerals();
@@ -204,7 +204,7 @@ public Area getMainArea(final TilePosition topLeft, final TilePosition size) {
204204
// //----------------------------------------------------------------------
205205
// // Area with the highest frequency.
206206
// //----------------------------------------------------------------------
207-
// final java.util.BWEMMap<Area, Integer> areaFrequency = new HashMap<>();
207+
// final java.util.BWMap<Area, Integer> areaFrequency = new HashMap<>();
208208
// for (int dy = 0; dy < size.getY(); ++dy)
209209
// for (int dx = 0; dx < size.getX(); ++dx) {
210210
// final Area area = getArea(topLeft.add(new TilePosition(dx, dy)));
@@ -218,8 +218,8 @@ public Area getMainArea(final TilePosition topLeft, final TilePosition size) {
218218
// }
219219
//
220220
// if (!areaFrequency.isEmpty()) {
221-
// java.util.BWEMMap.Entry<Area, Integer> highestFreqEntry = null;
222-
// for (final java.util.BWEMMap.Entry<Area, Integer> currentEntry :
221+
// java.util.BWMap.Entry<Area, Integer> highestFreqEntry = null;
222+
// for (final java.util.BWMap.Entry<Area, Integer> currentEntry :
223223
// areaFrequency.entrySet()) {
224224
// if (highestFreqEntry == null || (currentEntry.getValue() >
225225
// highestFreqEntry.getValue())) {

src/main/java/bwem/BWEMMapInitializer.java renamed to src/main/java/bwem/BWMapInitializer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import java.util.Collections;
2020
import java.util.List;
2121

22-
class BWEMMapInitializer extends BWEMMap {
23-
BWEMMapInitializer(final Game game) {
22+
class BWMapInitializer extends BWMap {
23+
BWMapInitializer(final Game game) {
2424
super(game);
2525
}
2626

@@ -83,7 +83,7 @@ private void initializeTerrainData(
8383
}
8484

8585
////////////////////////////////////////////////////////////////////////
86-
// BWEMMap::InitializeNeutrals
86+
// BWMap::InitializeNeutrals
8787
////////////////////////////////////////////////////////////////////////
8888

8989
private void initializeNeutralData(
@@ -96,7 +96,7 @@ private void initializeNeutralData(
9696
////////////////////////////////////////////////////////////////////////
9797

9898
////////////////////////////////////////////////////////////////////////
99-
// BWEMMap::ComputeAltitude
99+
// BWMap::ComputeAltitude
100100
////////////////////////////////////////////////////////////////////////
101101

102102
// Assigns MiniTile::m_altitude foar each miniTile having AltitudeMissing()
@@ -233,7 +233,7 @@ private Altitude setAltitudesAndGetUpdatedHighestAltitude(
233233
////////////////////////////////////////////////////////////////////////
234234

235235
////////////////////////////////////////////////////////////////////////
236-
// BWEMMap::processBlockingNeutrals
236+
// BWMap::processBlockingNeutrals
237237
////////////////////////////////////////////////////////////////////////
238238

239239
private void processBlockingNeutrals(final List<Neutral> candidates) {
@@ -413,7 +413,7 @@ private void markBlockingStackedNeutrals(
413413
////////////////////////////////////////////////////////////////////////
414414

415415
////////////////////////////////////////////////////////////////////////
416-
// BWEMMap::ComputeAreas
416+
// BWMap::ComputeAreas
417417
////////////////////////////////////////////////////////////////////////
418418

419419
// Assigns MiniTile::m_areaId for each miniTile having AreaIdMissing()
@@ -589,7 +589,7 @@ private void createAreas(final List<TempAreaInfo> tempAreaList, final int areaMi
589589
getGraph().createAreas(areasList);
590590
}
591591

592-
// Renamed from "BWEMMap::SetAltitudeInTile"
592+
// Renamed from "BWMap::SetAltitudeInTile"
593593
private void setLowestAltitudeInTile(final TilePosition t) {
594594
Altitude lowestAltitude = new Altitude(Integer.MAX_VALUE);
595595

@@ -609,7 +609,7 @@ private void setLowestAltitudeInTile(final TilePosition t) {
609609
getData().getTile(t).setLowestAltitude(lowestAltitude);
610610
}
611611

612-
// Renamed from "BWEMMap::SetAreaIdInTiles"
612+
// Renamed from "BWMap::SetAreaIdInTiles"
613613
private void setAreaIdAndLowestAltitudeInTiles() {
614614
for (int y = 0; y < getData().getMapData().getTileSize().getY(); ++y)
615615
for (int x = 0; x < getData().getMapData().getTileSize().getX(); ++x) {

src/main/java/bwem/CPPath.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.util.List;
1818

1919
/**
20-
* Type of all the Paths used in BWEM (Cf. BWEMMap::GetPath).
20+
* Type of all the Paths used in BWEM (Cf. BWMap::GetPath).
2121
*
2222
* <p>cp.h:68:typedef std::vector<const ChokePoint *> Path; cp.h:168:typedef ChokePoint::Path
2323
* CPPath;

src/main/java/bwem/ChokePoint.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Pos(middle), Pos(end1) and Pos(end2).<br>
3131
* ChokePoints play an important role in BWEM:<br>
3232
* - they define accessibility between Areas.<br>
33-
* - the Paths provided by BWEMMap::GetPath are made of ChokePoints.<br>
33+
* - the Paths provided by BWMap::GetPath are made of ChokePoints.<br>
3434
* Like Areas and Bases, the number and the addresses of ChokePoint instances remain unchanged.<br>
3535
* <br>
3636
* Pseudo ChokePoints:<br>
@@ -99,7 +99,7 @@ > getMap().getData().getMiniTile(geometry.get(i)).getAltitude().intValue())) {
9999
}
100100
this.nodes[Node.MIDDLE.ordinal()] = geometry.get(i);
101101

102-
BWEMMap map = getMap();
102+
BWMap map = getMap();
103103
for (int n = 0; n < Node.NODE_COUNT.ordinal(); ++n) {
104104
for (final Area area : new Area[]{area1, area2}) {
105105
final WalkPosition nodeInArea =
@@ -150,7 +150,7 @@ > getMap().getData().getMiniTile(geometry.get(i)).getAltitude().intValue())) {
150150
this(graph, index, area1, area2, geometry, null);
151151
}
152152

153-
private BWEMMap getMap() {
153+
private BWMap getMap() {
154154
return this.graph.getMap();
155155
}
156156

@@ -193,7 +193,7 @@ public WalkPosition getNodePosition(final Node node) {
193193

194194
/**
195195
* Pretty much the same as pos(n), except that the returned MiniTile position is guaranteed to be
196-
* part of pArea. That is: BWEMMap::getArea(positionOfNodeInArea(n, pArea)) == pArea.
196+
* part of pArea. That is: BWMap::getArea(positionOfNodeInArea(n, pArea)) == pArea.
197197
*/
198198
public WalkPosition getNodePositionInArea(final Node node, final Area area) {
199199
if (!(area.equals(this.areas.getLeft()) || area.equals(this.areas.getRight()))) {
@@ -219,7 +219,7 @@ public List<WalkPosition> getGeometry() {
219219
* If !isPseudo(), returns false. Otherwise, returns whether this ChokePoint is considered
220220
* blocked. Normally, a pseudo ChokePoint either remains blocked, or switches to not isBlocked
221221
* when blockingNeutral() is destroyed and there is no remaining Neutral stacked with it. However,
222-
* in the case where BWEMMap::automaticPathUpdate() == false, blocked() will always return true
222+
* in the case where BWMap::automaticPathUpdate() == false, blocked() will always return true
223223
* whatever blockingNeutral() returns. Cf. Area::AccessibleNeighbors().
224224
*/
225225
public boolean isBlocked() {
@@ -265,7 +265,7 @@ public boolean accessibleFrom(final ChokePoint chokePoint) {
265265
* - Note: if this == cp, returns [cp].<br>
266266
* Time complexity: O(1)<br>
267267
* To get the length of the path returned in pixels, use distanceFrom(cp).<br>
268-
* - Note: all the possible Paths are precomputed during BWEMMap::initialize().<br>
268+
* - Note: all the possible Paths are precomputed during BWMap::initialize().<br>
269269
* The best one is then stored for each pair of getChokePoints. However, only the center of the
270270
* getChokePoints is considered. As a consequence, the returned path may not be the shortest one.
271271
*/

src/main/java/bwem/Geyser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Resource_Vespene_Geyser.
2121
*/
2222
public final class Geyser extends Resource {
23-
Geyser(final Unit unit, final BWEMMap map) {
23+
Geyser(final Unit unit, final BWMap map) {
2424
super(unit, map);
2525

2626
if (!unit.getType().equals(UnitType.Resource_Vespene_Geyser)) {

src/main/java/bwem/Graph.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.*;
2525

2626
public final class Graph {
27-
private final BWEMMap map;
27+
private final BWMap map;
2828
private final List<Area> areas = new ArrayList<>();
2929
private final List<ChokePoint> chokePoints = new ArrayList<>();
3030
private final List<List<List<ChokePoint>>> chokePointsMatrix =
@@ -35,11 +35,11 @@ public final class Graph {
3535
new ArrayList<>(); // index == ChokePoint::index x ChokePoint::index
3636
private final List<Base> bases = new ArrayList<>();
3737

38-
public Graph(BWEMMap map) {
38+
public Graph(BWMap map) {
3939
this.map = map;
4040
}
4141

42-
public BWEMMap getMap() {
42+
public BWMap getMap() {
4343
return map;
4444
}
4545

@@ -104,7 +104,7 @@ public Area getNearestArea(final TilePosition tilePosition) {
104104
return getArea(t);
105105
}
106106

107-
// Returns the list of all the getChokePoints in the BWEMMap.
107+
// Returns the list of all the getChokePoints in the BWMap.
108108
public List<ChokePoint> getChokePoints() {
109109
return chokePoints;
110110
}
@@ -345,8 +345,8 @@ public void createChokePoints(
345345
final List<WalkPosition> rawFrontierAB = entry.getValue();
346346

347347
// Because our dispatching preserved order,
348-
// and because BWEMMap::m_RawFrontier was populated in descending order of the altitude (see
349-
// BWEMMap::computeAreas),
348+
// and because BWMap::m_RawFrontier was populated in descending order of the altitude (see
349+
// BWMap::computeAreas),
350350
// we know that rawFrontierAB is also ordered the same way, but let's check it:
351351
{
352352
final List<Altitude> altitudes = new ArrayList<>();
@@ -498,7 +498,7 @@ public void computeChokePointDistanceMatrix() {
498498
}
499499

500500
public void collectInformation() {
501-
// 1) Process the whole BWEMMap:
501+
// 1) Process the whole BWMap:
502502

503503
for (final Mineral mineral : getMap().getNeutralData().getMinerals()) {
504504
final Area area = getMap().getMainArea(mineral.getTopLeft(), mineral.getSize());

src/main/java/bwem/Mineral.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* getType().isMineralField().
2020
*/
2121
public final class Mineral extends Resource {
22-
Mineral(final Unit unit, final BWEMMap map) {
22+
Mineral(final Unit unit, final BWMap map) {
2323
super(unit, map);
2424

2525
// bwem_assert(Type().isMineralField());

0 commit comments

Comments
 (0)