<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=259640&amp;view=findpost&amp;p=2142495</guid>
        <pubDate>Sun, 14 Dec 2008 07:00:12 +0000</pubDate>
        <title>Игра ввосьмерку на Lisp</title>
        <link>https://forum.sources.ru/index.php?showtopic=259640&amp;view=findpost&amp;p=2142495</link>
        <description><![CDATA[OlyA8: Спасибо, уже рзобралась&#33;)) :D]]></description>
        <author>OlyA8</author>
        <category>Lisp</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=259640&amp;view=findpost&amp;p=2142403</guid>
        <pubDate>Sat, 13 Dec 2008 21:16:09 +0000</pubDate>
        <title>Игра ввосьмерку на Lisp</title>
        <link>https://forum.sources.ru/index.php?showtopic=259640&amp;view=findpost&amp;p=2142403</link>
        <description><![CDATA[OlyA8: Вот прошу помочь мне доделать задачку про Восьмерку&#33; смысл в том что в квадрате 8х8 есть цифры от 0 до 7 и пустое место b. необходимо перемещать цифры так чтобы они из перемешанного состояния по порядку выстроились. то есть из <br>
0 1 2<br>
3 4 5<br>
6   7<br>
(0 1 2 3 4 5 6 7 b).<br>
вот как у меня выводится<br>
(breadth-first-search &#39;(0 1 2 3 4 5 6 b 7))<br>
&quot;&quot;Najdeno (0 1 2 3 4 5 6 7 B) za 3 shaga. <br>
Rasshiril 9 uzla, hranil maximum 5 uzlov.&quot;<br>
<br>
<br>
А как сделать так чтобы и сами шаги перебора выводились, то есть когда меняет местами цифры - это выводить как бы по шагам.<br>
<br>
вот, часть кода.<br>
 [CODE] <br>
<br>
(defun successors (grid)<br>
  &quot;Return a list of new grids consisting of all possible moves from<br>
GRID.&quot;<br>
  (delete nil (list (up grid)<br>
		    (down grid)<br>
		    (left grid)<br>
		    (right grid))))<br>
<br>
(defun finished? (grid)<br>
  &quot;Return T if GRID is in perfect order with the &#39;hole&#39; at the end,<br>
NIL otherwise.&quot;<br>
  (equal grid &#39;(0 1 2 3 4 5 6 7 b)))<br>
<br>
(defun breadth-first-search (start)<br>
  (let ((open (list start)) ; the list of nodes to be examined<br>
	(closed (list)) ; the list of nodes already examined<br>
	(steps 0) ; number of iterations<br>
	(expanded 0) ; total number of nodes expanded<br>
	(stored 0)) ; max number of nodes stored at any one time<br>
    (loop while open do<br>
	  (let ((x (pop open))) <br>
	    (when (finished? x)<br>
	      (return (format nil &quot;Najdeno ~a za ~a shaga.<br>
     Rasshiril ~a uzla, hranil maximum ~a uzlov.&quot; x steps expanded stored)))<br>
	    (incf steps)<br>
	    (pushnew x closed :test #&#39;equal)<br>
	    (let ((successors (successors x)))<br>
	      (incf expanded (length successors))<br>
	      (setq successors<br>
		    (delete-if (lambda (a)<br>
				 (or (find a open :test #&#39;equal)<br>
				     (find a closed :test #&#39;equal)))<br>
			       successors))<br>
	      (setq open (append open successors))<br>
	      (setq stored (max stored (length open))))))))<br>
<br>
Если мало комментариев - поясню, просто билась с не долго так, вот очень прошу помочь доделать&#33; если что - в ответ тоже что нибудь помогу&#33; просто вот досталась задачка))]]></description>
        <author>OlyA8</author>
        <category>Lisp</category>
      </item>
	
      </channel>
      </rss>
	