diff options
author | pacien | 2018-02-04 14:46:28 +0100 |
---|---|---|
committer | pacien | 2018-02-04 14:46:28 +0100 |
commit | 466faf36b54019cb345c7d0193e6cc318ea39da6 (patch) | |
tree | 6d46c37a17cb7e2a1f0d6cb2e68e28e9fd09f253 | |
parent | 0f483e78be455b583cc983007a290f6976784c82 (diff) | |
download | wallj-466faf36b54019cb345c7d0193e6cc318ea39da6.tar.gz |
Prevent useless backtracking
Signed-off-by: pacien <pacien.trangirard@pacien.net>
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/board/PathFinder.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/board/PathFinder.java b/src/main/java/fr/umlv/java/wallj/board/PathFinder.java index dfd1fa6..098b4a2 100644 --- a/src/main/java/fr/umlv/java/wallj/board/PathFinder.java +++ b/src/main/java/fr/umlv/java/wallj/board/PathFinder.java | |||
@@ -73,11 +73,11 @@ public class PathFinder { | |||
73 | 73 | ||
74 | double challengeCost = cost(searchData, current) + neighborEntry.getValue(); | 74 | double challengeCost = cost(searchData, current) + neighborEntry.getValue(); |
75 | double currentCost = cost(searchData, neighborEntry.getKey()); | 75 | double currentCost = cost(searchData, neighborEntry.getKey()); |
76 | if (challengeCost < currentCost) | 76 | if (challengeCost < currentCost) { |
77 | searchData.put(neighborEntry.getKey(), new NodeSearchData<>(current, challengeCost, | 77 | searchData.put(neighborEntry.getKey(), new NodeSearchData<>(current, challengeCost, |
78 | challengeCost + heuristic.apply(neighborEntry.getKey().val, target))); | 78 | challengeCost + heuristic.apply(neighborEntry.getKey().val, target))); |
79 | 79 | discovered.add(neighborEntry.getKey()); | |
80 | discovered.add(neighborEntry.getKey()); | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | visited.add(current); | 83 | visited.add(current); |