summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-04 16:15:09 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-04 16:15:09 +0100
commit4c7a6b39fcec76697a90fba446987bc4a869b824 (patch)
treea6d4ea00bea20e0b46ee6194aeed7ce13b446cde /core/src/ch/asynk/rustanddust
parent5ec7fa718f99968c6823ab87e27a2e96f586f77d (diff)
downloadRustAndDust-4c7a6b39fcec76697a90fba446987bc4a869b824.zip
RustAndDust-4c7a6b39fcec76697a90fba446987bc4a869b824.tar.gz
PathBuilder: do not compute distance if from == to
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathBuilder.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
index 9955b92..28527d7 100644
--- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
+++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
@@ -106,13 +106,15 @@ public class PathBuilder implements Disposable
clear();
this.to = to;
// from and to are not part of the path
- this.distance = board.distance(from, to);
- if (distance == 0) {
+ if (from == to) {
+ this.distance = 0;
Path path = Path.get(0);
path.cost = 0;
paths.add(path);
- } else
+ } else {
+ this.distance = board.distance(from, to);
findAllPaths(from, pawn.getMovementPoints(), 0, true);
+ }
// printToErr("paths", paths);
stack.clear();