Created
July 4, 2009 12:46
-
-
Save fffej/140556 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 beam-search | |
"Search highest scoring states first until goal is reached" | |
[start goal? successors cost-fn beam-width] | |
(tree-search (list start) goal? successors | |
(fn [old new] | |
(let [sorted ((sorter cost-fn) old new)] | |
(if (> beam-width (count sorted)) | |
sorted | |
(take beam-width sorted)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment