Created
July 4, 2009 12:36
-
-
Save fffej/140555 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn sorter | |
"Return a combiner function that sorts according to cost-fn" | |
[cost-fn] | |
(fn [new old] | |
(sort (fn [n o] (< (cost-fn n) (cost-fn o))) (concat new old)))) | |
(defn best-first-search | |
"Search lowest cost states first until goal is reached" | |
[start goal? successors cost-fn] | |
(tree-search (list start) goal? successors (sorter cost-fn))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment