Skip to content

Instantly share code, notes, and snippets.

@mzdravkov
Last active December 24, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzdravkov/6730316 to your computer and use it in GitHub Desktop.
Save mzdravkov/6730316 to your computer and use it in GitHub Desktop.
An attempt (fail) to create ultra simple path finding algorithm in maze in Clojure.
; 'from' is the current point of search, 'to' is the target, level is the maze/2DMatrix
(defn pathar
([level from to] (pathar level from to []))
([level from to path]
(if (= from to)
path
(let [nb (valid-neighbours level from)] ;valid neighbours returns the indexes of all valid (in the 2dmatrix) neighbour elements.
(pmap #(pathar level % to (cons from path)) nb)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment