Skip to content

Instantly share code, notes, and snippets.

@fffej
Created February 15, 2021 15:49
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 fffej/ac431a23764a93c16556dde0db0bc76c to your computer and use it in GitHub Desktop.
Save fffej/ac431a23764a93c16556dde0db0bc76c to your computer and use it in GitHub Desktop.
(defun tree-search (states goal-p successors combiner)
"Find a state that satisfies goal-p. Start with states,
and search according to successors and combiner."
(dbg :search "~&;; Search: ~a" states)
(cond ((null states) fail)
((funcall goal-p (first states)) (first states))
(t (tree-search
(funcall combiner
(funcall successors (first states))
(rest states))
goal-p successors combiner))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment