summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-04 16:09:08 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-04 16:09:08 +0100
commit98dd87bc85fd0962efbfc861e762e9c3549b2ee5 (patch)
tree3c26f30805e5e5c9276b2b74f33dbea74c7b0a7b /core/src/ch
parentfc2ea1292a302417053036b23e433d0c0645e3d3 (diff)
downloadRustAndDust-98dd87bc85fd0962efbfc861e762e9c3549b2ee5.zip
RustAndDust-98dd87bc85fd0962efbfc861e762e9c3549b2ee5.tar.gz
PathBuilder: if (from == to) build empty path
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathBuilder.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
index af5d78b..9d564b5 100644
--- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
+++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
@@ -107,7 +107,12 @@ public class PathBuilder implements Disposable
this.to = to;
// from and to are not part of the path
this.distance = board.distance(from, to);
- findAllPaths(from, pawn.getMovementPoints(), 0, true);
+ if (distance == 0) {
+ Path path = Path.get(0);
+ path.cost = 0;
+ paths.add(path);
+ } else
+ findAllPaths(from, pawn.getMovementPoints(), 0, true);
// printToErr("paths", paths);
stack.clear();