slightly better pathfinding.

This commit is contained in:
=
2014-09-08 14:17:29 -07:00
parent 0507b26cca
commit 0e44cea2f5

View File

@@ -43,8 +43,11 @@
(came-from current-node))))))
(defn heuristic [[goal-x goal-y] [current-x current-y]]
(+ (Math/abs (- goal-x current-x ))
(Math/abs (- goal-y current-y))))
(let [dist-x (Math/abs (- goal-x current-x ))
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]
(vec (map (fn [x] (int (/ x 2))) loc)))