slightly better pathfinding.
This commit is contained in:
@@ -43,8 +43,11 @@
|
|||||||
(came-from current-node))))))
|
(came-from current-node))))))
|
||||||
|
|
||||||
(defn heuristic [[goal-x goal-y] [current-x current-y]]
|
(defn heuristic [[goal-x goal-y] [current-x current-y]]
|
||||||
(+ (Math/abs (- goal-x current-x ))
|
(let [dist-x (Math/abs (- goal-x current-x ))
|
||||||
(Math/abs (- goal-y current-y))))
|
dist-y (Math/abs (- goal-y current-y))
|
||||||
|
d2 (Math/sqrt 2)]
|
||||||
|
(+ dist-x dist-y (* (- d2 1)
|
||||||
|
(min dist-x dist-y)))))
|
||||||
|
|
||||||
(defn ->scale [loc]
|
(defn ->scale [loc]
|
||||||
(vec (map (fn [x] (int (/ x 2))) loc)))
|
(vec (map (fn [x] (int (/ x 2))) loc)))
|
||||||
|
|||||||
Reference in New Issue
Block a user