File tree Expand file tree Collapse file tree 7 files changed +17
-42
lines changed
Expand file tree Collapse file tree 7 files changed +17
-42
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,6 @@ void initialize() {
6868
6969 getGraph ().collectInformation ();
7070
71-
7271 getGraph ().createBases (getData ());
7372 }
7473
@@ -649,8 +648,7 @@ void onBlockingNeutralDestroyed(Neutral pBlocking) {
649648 // Unblock the Tiles of pBlocking:
650649 for (int dy = 0 ; dy < pBlocking .getSize ().getY (); ++dy )
651650 for (int dx = 0 ; dx < pBlocking .getSize ().getX (); ++dx ) {
652- getData ()
653- .getTile (pBlocking .getTopLeft ().add (new TilePosition (dx , dy )))
651+ getData ().getTile (pBlocking .getTopLeft ().add (new TilePosition (dx , dy )))
654652 .resetAreaId ();
655653 setAreaIdInTile (pBlocking .getTopLeft ().add (new TilePosition (dx , dy )));
656654 }
Original file line number Diff line number Diff line change 1818import bwapi .WalkPosition ;
1919import bwem .util .BwemExt ;
2020import bwem .util .CheckMode ;
21+ import bwem .util .Pred ;
2122import bwem .util .Utils ;
2223
2324import java .util .*;
@@ -80,7 +81,7 @@ public Area getNearestArea(final WalkPosition walkPosition) {
8081 // findCond
8182 (MiniTile miniTile , WalkPosition unused ) -> (miniTile .getAreaId ().intValue () > 0 ),
8283 // visitCond
83- ( MiniTile miniTile , WalkPosition unused ) -> true );
84+ Pred . accept () );
8485
8586 return getArea (w );
8687 }
@@ -338,7 +339,7 @@ public void createChokePoints(
338339 // findCond
339340 (MiniTile miniTile , WalkPosition unused ) -> miniTile .isWalkable (),
340341 // visitCond
341- ( MiniTile miniTile , WalkPosition unused ) -> true );
342+ Pred . accept () );
342343
343344 final List <WalkPosition > list = new ArrayList <>();
344345 list .add (center );
Original file line number Diff line number Diff line change 33/**
44 * Result of a path query including the approximated length of the path.
55 */
6- public class PathingResult {
6+ public final class PathingResult {
77
88 private final CPPath cpPath ;
99 private final int approxDistance ;
Original file line number Diff line number Diff line change @@ -210,27 +210,12 @@ void setInternalData(int internalData) {
210210 * Corresponds to BWAPI::getGroundHeight divided by 2.
211211 */
212212 public enum GroundHeight {
213- LOW_GROUND ( 0 ),
214- HIGH_GROUND ( 1 ),
215- VERY_HIGH_GROUND ( 2 );
213+ LOW_GROUND , // Height 0
214+ HIGH_GROUND , // Height 1
215+ VERY_HIGH_GROUND ; // Height 2
216216
217- private final int val ;
218-
219- GroundHeight (final int val ) {
220- this .val = val ;
221- }
222-
223- static GroundHeight parseGroundHeight (final int height ) {
224- for (final GroundHeight val : GroundHeight .values ()) {
225- if (val .intValue () == height ) {
226- return val ;
227- }
228- }
229- throw new IllegalArgumentException ("Unrecognized height: " + height );
230- }
231-
232- int intValue () {
233- return this .val ;
217+ static GroundHeight parseGroundHeight (int height ) {
218+ return values ()[height ];
234219 }
235220 }
236221}
Original file line number Diff line number Diff line change @@ -22,22 +22,13 @@ public final class Markable {
2222
2323 public Markable (final StaticMarkable staticMarkable ) {
2424 this .staticMarkable = staticMarkable ;
25- this .lastMark = 0 ;
26- }
27-
28- private StaticMarkable getStaticMarkable () {
29- return this .staticMarkable ;
3025 }
3126
3227 public boolean isUnmarked () {
33- return (this .lastMark != getStaticMarkable () .getCurrentMark ());
28+ return (this .lastMark != staticMarkable .getCurrentMark ());
3429 }
3530
3631 public void setMarked () {
37- this .lastMark = getStaticMarkable ().getCurrentMark ();
38- }
39-
40- public void setUnmarked () {
41- this .lastMark = getStaticMarkable ().getCurrentMark () - 1 ;
32+ this .lastMark = staticMarkable .getCurrentMark ();
4233 }
4334}
Original file line number Diff line number Diff line change 1515@ FunctionalInterface
1616public interface Pred <T , P > {
1717 boolean test (T tile , P position );
18+
19+ static <T , P > Pred <T , P > accept () {
20+ return (tile , position ) -> true ;
21+ }
1822}
Original file line number Diff line number Diff line change 1919public final class StaticMarkable {
2020 private int currentMark ;
2121
22- public StaticMarkable () {
23- this .currentMark = 0 ;
24- }
25-
26- public int getCurrentMark () {
22+ int getCurrentMark () {
2723 return this .currentMark ;
2824 }
2925
You can’t perform that action at this time.
0 commit comments