我一直被困在這個問題上好幾天。顯然我需要編寫一個更好的算法來贏得下面的算法。下面的代碼是從着名的艾瑪文件實現的。這裏有沒有專家可以指導我如何贏得算法?實施更快的算法
(defun find-closest (list)
(x (car (array-dimensions list)))
(y (cadr (array-dimensions list)))
(let ((elems (aref list x y)))
(dolist (e elems)
(when (eq (type-of e) type)
(return-from find-closest (list x y)))) nil))
我試着實現一個DFS,但失敗了,我不知道爲什麼。以下是我的代碼。
(defun find-closest (list)
(let ((open (list list))
(closed (list))
(steps 0)
(expanded 0)
(stored 0))
(loop while open do
(let ((x (pop open)))
(when (finished? x)
(return (format nil "Found ~a in ~a steps.
Expanded ~a nodes, stored a maximum of ~a nodes." x steps expanded stored)))
(incf steps)
(pushnew x closed :test #'equal)
(let ((successors (successors x)))
(incf expanded (length successors))
(setq successors
(delete-if (lambda (a)
(or (find a open :test #'equal)
(find a closed :test #'equal)))
successors))
(setq open (append open successors))
(setq stored (max stored (length open))))))))
這不是一個更好的職位[Code Review SE](http://codereview.stackexchange.com/)? – Sylwester
什麼是Code Review SE。對不起,我還是比較新的 – Hero1134
@Sylwester在代碼審查中這將成爲題外話題,因爲代碼似乎不能正常工作,因爲作者正在尋找一些fhelp來使代碼工作。參見[Stack Overflow用戶代碼評論指南](http://meta.codereview.stackexchange.com/questions/5777/a-guide-to-code-review-for-stack-overflow-users) – Phrancis