From 98dd87bc85fd0962efbfc861e762e9c3549b2ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 4 Jan 2016 16:09:08 +0100 Subject: PathBuilder: if (from == to) build empty path --- core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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(); -- cgit v1.1-2-g2b99