주어진 문제에 대해 제한된 깊이의 검색을 수행하는 코드를 작성하려고합니다.이 언어에 매우 익숙하지 않으므로 기본적으로 생각 만합니다. 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