repl jack-in.
This commit is contained in:
@@ -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)])))
|
||||
|
||||
@@ -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 ))
|
||||
|
||||
Reference in New Issue
Block a user