Hey im making an A* search on a eight puzzle and I have 2 main questions.
FIXED: First I get clojure.lang.Lazysez cannot be cast to clojure.lang.IFn when I run this on the line in the second part of the polymorph in the for loop but im not sure why.
Here is my code:
(defn a-star
([board history]
(if (at-end? board) (println board)
(
(let [options (filter #(possible-move? % board) *moves*)
move (into (pm/priority-map) (for [move options] [move (global-man-dis (move-tile board move))]))]
(for [pair move :let [next-move (key pair)]]
(do
(println (move-tile board next-move))
(a-star (move-tile board next-move) next-move (conj history board))
)
)
)
)))
([board prev-move history]
(if (or (at-end? board) (history-check history board)) (println board)
(
(let [options (get-queue board (dont-go-back prev-move))
move (into (pm/priority-map) (for [move options] [move (global-man-dis (move-tile board move))]))]
(for [pair move :let [next-move (key pair)]]
(do
(println (move-tile board next-move))
(a-star (move-tile board next-move) next-move (conj history board))
)
)
)
))))
(defn -main [& args]
(println "insert a list all numbers no spaces or letters")
(def board (mapv (fn [^Character c] (Character/digit c 10)) (read-line)))
;(def testt [0 8 4 7 2 1 3 5 6])
;(def testt [1 2 3 5 4 6 8 0 7])
(a-star board [])
)
Tried since post: removing "else" parens around let statement but now returns nothing FIXED removed the else parenthesis and changed for to doseq as for is lazy and wont output anything in this case. ill ask the other question seperatly again