嘗試寫代碼做一個有限的深度優先搜索在給定的問題和限制..即時通訊使用這種語言很新,所以這是basicly只是一些想法..不要欺負我由xDCLISP - 有限深度優先搜索
(defstruct state
pos
vel
action
cost
track
other)
(defstruct problem
initial-state
fn-nextStates
fn-isGoal
fn-h);heuristic funtion
(defstruct node
parent
state)
(defun limdepthfirstsearch (problem limit)
(return (recursiveldfs make-node(problem-initial-state) problem limit)))
(defun recursiveldfs (node problem limit)
(if (problem-fn-isGoal (node-state node)) (solution(node)))
(if (= limit 0) ':corte)
(setf (cutoff_ocurred) nil)
(loop for each (possible-actions) in (problem-fn-nextstates(node-state node)) do
(setf (child) (nextState (node-state node) (possible-actions)))
(setf (result) (recursiveldfs child problem (- limit 1)))
(if (= result ':corte) (setf (cutoff_ocurred) t))
(if (!= result nil) (return result))
)
(if (= cutoff_ocurred t) '(:corte))
(if (= cutoff_ocurred nil) nil)
)
嗨@xicocana!請查看http://stackoverflow.com/help/how-to-ask。這裏的用戶通常希望在嘗試幫助之前看清明確的問題並提供明確的解決方案......(即,您運行了什麼,包括測試數據,您觀察到了什麼,您期望觀察的是什麼,您嘗試過什麼解決問題?) – BadZen