aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/fr
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/fr')
-rw-r--r--src/main/java/fr/umlv/java/wallj/board/PathFinder.java4
1 files changed, 2 insertions, 2 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 c530d83..dfd1fa6 100644
--- a/src/main/java/fr/umlv/java/wallj/board/PathFinder.java
+++ b/src/main/java/fr/umlv/java/wallj/board/PathFinder.java
@@ -57,7 +57,7 @@ public class PathFinder {
57 57
58 private static <T> List<T> findPath(Node<T> start, T target, BiFunction<T, T, Double> heuristic) { 58 private static <T> List<T> findPath(Node<T> start, T target, BiFunction<T, T, Double> heuristic) {
59 Map<Node<T>, NodeSearchData<T>> searchData = new HashMap<>(); 59 Map<Node<T>, NodeSearchData<T>> searchData = new HashMap<>();
60 TreeSet<Node<T>> discovered = new TreeSet<>(Comparator.comparingDouble(n -> searchData.get(n).estimatedCost)); 60 Queue<Node<T>> discovered = new PriorityQueue<>(Comparator.comparingDouble(n -> searchData.get(n).estimatedCost));
61 Set<Node<T>> visited = new HashSet<>(); 61 Set<Node<T>> visited = new HashSet<>();
62 62
63 searchData.put(start, new NodeSearchData<>(null, 0, heuristic.apply(start.val, target))); 63 searchData.put(start, new NodeSearchData<>(null, 0, heuristic.apply(start.val, target)));
@@ -65,7 +65,7 @@ public class PathFinder {
65 65
66 Node<T> current; 66 Node<T> current;
67 while (!discovered.isEmpty()) { 67 while (!discovered.isEmpty()) {
68 current = discovered.pollFirst(); 68 current = discovered.poll();
69 if (target.equals(current.val)) return buildPath(searchData, current); 69 if (target.equals(current.val)) return buildPath(searchData, current);
70 70
71 for (Map.Entry<Node<T>, Integer> neighborEntry : current.neighbors.entrySet()) { 71 for (Map.Entry<Node<T>, Integer> neighborEntry : current.neighbors.entrySet()) {