diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-05-03 16:24:32 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-05-03 16:24:32 +0200 |
commit | 008ce9d87aabc0fa64753cf9c619a7718968ea3f (patch) | |
tree | 9d241a9cf1b9e09c38596743d2b42498364d0bc5 /core/src/ch/asynk | |
parent | 072cc1e97e942f8dd2654fbf59d109516621d1f0 (diff) | |
download | RustAndDust-008ce9d87aabc0fa64753cf9c619a7718968ea3f.zip RustAndDust-008ce9d87aabc0fa64753cf9c619a7718968ea3f.tar.gz |
PathBuilder: automaticaly filter paths with objectives
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java index fe98041..35eb997 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java +++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java @@ -21,11 +21,13 @@ public class PathBuilder implements Disposable private Collection<Path> paths; private Collection<Path> filteredPaths; private IterableSet<Tile> tiles; + private IterableSet<Tile> objectives; public PathBuilder(Board board, int tSize, int stSize, int ftSize, int psSize) { this.board = board; this.tiles = new IterableSet<Tile>(tSize); + this.objectives = new IterableSet<Tile>(tSize); this.stack = new IterableStack<Tile>(stSize); this.ctrlTiles = new IterableArray<Tile>(ftSize); this.paths = new IterableArray<Path>(psSize); @@ -76,6 +78,7 @@ public class PathBuilder implements Disposable { for (Path path : this.paths) path.dispose(); this.tiles.clear(); + this.objectives.clear(); this.stack.clear(); this.ctrlTiles.clear(); this.paths.clear(); @@ -112,11 +115,13 @@ public class PathBuilder implements Disposable } else { this.distance = board.distance(from, to); findAllPaths(from, pawn.getMovementPoints(), 0, true); + for (Tile t : objectives) + toggleCtrlTile(t, false); } // printToErr("paths", paths); stack.clear(); - return paths.size(); + return getPaths().size(); } public int chooseBest() @@ -214,7 +219,11 @@ public class PathBuilder implements Disposable Orientation o = board.getSide(i); int m = (mvtLeft - next.costFrom(pawn, o)); - int f = (fitness + (next.isObjectiveFor(pawn) ? 1 : 0)); + int f = fitness; + if (next.isObjectiveFor(pawn)) { + f += 1; + objectives.add(next); + } boolean r = (roadMarch && next.roadFrom(o)); int l = (m + (r ? pawn.getRoadMarchBonus() : 0)); |