Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn next-directed-cells [ mapref cell destination ]
- "Ranks all valid neighbouring cells according to their distance to the desired direction"
- (let [valid-neighbours (valid-neighbouring-cells mapref cell)
- normalised-direction (first
- (normalise (substract-points destination cell)))
- translated-to-0 (map (fn [v] (substract-points v cell)) valid-neighbours)
- distances (map
- (fn [v]
- (euclidean-distance (first (normalise v))
- normalised-direction))
- translated-to-0)
- zipped-distances (partition 2 (interleave valid-neighbours distances))]
- (map first
- (sort (fn [[_ d1] [_ d2]] (< d1 d2))
- zipped-distances))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement