repl jack-in.

This commit is contained in:
=
2014-09-11 13:03:26 -07:00
parent dc40512eda
commit 8ebd46a935
3 changed files with 25 additions and 13 deletions

View File

@@ -45,7 +45,7 @@
(defn from-path [screen entities target-id [x y]]
(let [entity (target-id entities)
path (vec (take-nth 4 (advent.pathfind/visit-all
path (vec (take-nth 5 (advent.pathfind/visit-all
(:collision (:background entities))
[(int (:x entity)) (int (:y entity))]
[(int x) (int y)])))

View File

@@ -31,16 +31,16 @@
(defn resolve-path [came-from play-loc target-loc]
(doto (if (nil? (came-from target-loc))
nil
(loop [path []
current-node target-loc]
(if (or (= current-node play-loc)
(nil? current-node))
(reverse (map (fn [[x y]] [x y]) (conj path current-node)))
(recur
(conj path current-node)
(came-from current-node))))) println))
(if (nil? (came-from target-loc))
nil
(loop [path []
current-node target-loc]
(if (or (= current-node play-loc)
(nil? current-node))
(reverse (map (fn [[x y]] [x y]) (conj path current-node)))
(recur
(conj path current-node)
(came-from current-node))))))
(defn heuristic [[goal-x goal-y] [current-x current-y]]
(let [dist-x (Math/abs (- goal-x current-x ))