diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 12:19:54 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 12:19:54 +0100 |
commit | 77714a9d5cb226889e820279f73e3444a38a17f3 (patch) | |
tree | 7c34fe7b1cbc5c680ed53019ffa8f3e1bda711b2 /core | |
parent | 2d90eee737b2762d202152c720d34eebf34d0e96 (diff) | |
download | RustAndDust-77714a9d5cb226889e820279f73e3444a38a17f3.zip RustAndDust-77714a9d5cb226889e820279f73e3444a38a17f3.tar.gz |
PathBuilder: fix for at least one move
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java index c458369..16c2f86 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java +++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java @@ -154,18 +154,19 @@ public class PathBuilder implements Disposable int l = (m + (r ? pawn.getRoadMarchBonus() : 0)); - if (board.distance(next, to) <= l) { - if (next == to) { - Path path = Path.get(stack.size() + 1); - for (Tile t: stack) { - path.tiles.add(t); - tiles.add(t); - } - path.roadMarch = r; - path.fitness = f; - path.cost = (pawn.getMovementPoints() - m); - paths.add(path); + if ((next == to) && ((l >= 0) || ((stack.size() == 0) && next.atLeastOneMove(pawn)))) { + Path path = Path.get(stack.size() + 1); + for (Tile t: stack) { + path.tiles.add(t); + tiles.add(t); } + path.roadMarch = r; + path.fitness = f; + path.cost = (pawn.getMovementPoints() - m); + paths.add(path); + } + + if (l >= board.distance(next, to)) { stack.add(next); findAllPaths(next, m, f, r); stack.remove(stack.size() - 1); |