Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
лаб4.docx
Скачиваний:
9
Добавлен:
29.09.2024
Размер:
966 Кб
Скачать
☆

Пример работы программы:

На рисунках 3-7 приведены скриншоты работы программы, а именно диалоговое окно и список фактов. На рисунке 3 приведена инициализация структуры данных программы:

Рисунок 3 - инициализация структуры данных.

На рисунке 4 приведены результаты работы программы с эвристикой h1 в сквозном режиме:

Рисунок 4 - эвристика h1, сквозной режим

На рисунке 5 приведены результаты работы программы с эвристикой h1 в сквозном режиме:

Рисунок 5 - эвристика h1, пошаговый режим

На рисунке 6 приведены результаты работы с эвристикой h2 в сквозном режиме.

Рисунок 6 - эвристика h2, сквозной режим

На рисунке 7 приведены результаты работы с эвристикой h2 в пошаговом режиме

Рисунок 7 - эвристика h2, пошаговый режим

Сравнение временной и ёмкостной сложности алгоритмов:

Реализация на императивном языке

Реализация на продукционном языке

Алгоритм A* с эвристикой h1

Алгоритм A* с эвристикой h2

Алгоритм A* с эвристикой h1

Алгоритм A* с эвристикой h2

Временная сложность (кол-во шагов)

1393

257

1394

170

Ёмкостная сложность (кол-во уникальных вершин в дереве поиска)

2224

426

2251

273

Вывод:

В результате выполнения работы мы успешно реализовали алгоритм эвристического поиска А* для игры “Восьмерка” в среде продукционного программирования CLIPS. Написали две эвристические функции: h1 – подсчет ячеек не на своих местах, h2 – манхэттенское расстояние. Закрепили понимание основных конструкций языка CLIPS и парадигмы продукционного программирования. Было произведено сравнение получившийся реализации с реализацией на императивном языке программирования (в нашем случае - Python). Сравнение показало, что эвристика h1 незначительно дольше работает на продукционном языке программирования, однако использование эвристики h2 в среде CLIPS дало ощутимое падение как временной сложности, так и ёмкостной сложности. Это связано с разным подходом к реализации одной и той же задачи в разных парадигмах программирования, а, в следствии, и в различных итоговых алгоритмах прохождения по дереву поиска.

Исходный код

Файл Run_Lab_4.bat:

(load rulebase.CLP)

(reset)

(run)

Файл rulebase.CLP:

(defglobal

?*ID* = 0

?*unique_nodes* = 1

?*total_steps* = 0

;; original state

?*initial_cell1* = 8

?*initial_cell2* = 7

?*initial_cell3* = 3

?*initial_cell4* = 1

?*initial_cell5* = 5

?*initial_cell6* = 6

?*initial_cell7* = 4

?*initial_cell8* = 2

?*initial_cell9* = 0

;; goal state

?*result_cell1* = 1

?*result_cell2* = 2

?*result_cell3* = 3

?*result_cell4* = 4

?*result_cell5* = 5

?*result_cell6* = 6

?*result_cell7* = 7

?*result_cell8* = 8

?*result_cell9* = 0

;; EF=1:h1 (количество фишек не на своем месте); EF=2:h2 (сумма всех манхэттенских расстояний фишек до целевых позиций); DB=1:steps

?*hType* = 2

?*DEBUG* = 1

)

;; Node template

(deftemplate Node

(slot id(type NUMBER) (default 0))

(slot cell1 (type NUMBER))

(slot cell2 (type NUMBER))

(slot cell3 (type NUMBER))

(slot cell4 (type NUMBER))

(slot cell5 (type NUMBER))

(slot cell6 (type NUMBER))

(slot cell7 (type NUMBER))

(slot cell8 (type NUMBER))

(slot cell9 (type NUMBER))

(slot parent (type NUMBER))

(slot depth (type NUMBER))

(slot f (type NUMBER)) ; значение целевой функции для данной вершины f = depth + h

(slot status(type NUMBER) (default 0)) ; 0 – не раскрыта, 1 – раскрыта, 2 – соответствует решению

)

;; manhattan distance

(deffunction manhattanGeom (?v ?i ?j)

(if (eq ?v 0) then

(return 0))

(bind ?i_g (div (- ?v 1) 3)) ; Goal row

(bind ?j_g (mod (- ?v 1) 3)) ; Goal column

(return (+ (abs (- ?i ?i_g)) (abs (- ?j ?j_g))))

)

;; Euristhics h1

(deffunction h1(?cur_cell1 ?cur_cell2 ?cur_cell3 ?cur_cell4 ?cur_cell5 ?cur_cell6 ?cur_cell7 ?cur_cell8 ?cur_cell9)

(bind ?current (create$ ?cur_cell1 ?cur_cell2 ?cur_cell3 ?cur_cell4 ?cur_cell5 ?cur_cell6 ?cur_cell7 ?cur_cell8 ?cur_cell9))

(bind ?goal (create$ ?*result_cell1* ?*result_cell2* ?*result_cell3* ?*result_cell4* ?*result_cell5* ?*result_cell6* ?*result_cell7* ?*result_cell8* ?*result_cell9*))

(bind ?a 0)

(loop-for-count (?i 1 9)

(if (not (= (nth ?i ?current) (nth ?i ?goal))) then

(bind ?a (+ ?a 1))

)

)

(return ?a)

)

;; Euristhics h2

(deffunction h2(?cur_cell1 ?cur_cell2 ?cur_cell3 ?cur_cell4 ?cur_cell5 ?cur_cell6 ?cur_cell7 ?cur_cell8 ?cur_cell9)

(bind ?current (create$ ?cur_cell1 ?cur_cell2 ?cur_cell3 ?cur_cell4 ?cur_cell5 ?cur_cell6 ?cur_cell7 ?cur_cell8 ?cur_cell9))

(bind ?a 0)

(loop-for-count (?i 1 9)

(bind ?row (div (- ?i 1) 3))

(bind ?col (mod (- ?i 1) 3))

(bind ?a (+ ?a (manhattanGeom (nth ?i ?current) ?row ?col)))

)

(return ?a)

)

;; counting euristhics

(deffunction getF(?depth

?cur_cell1 ?cur_cell2 ?cur_cell3

?cur_cell4 ?cur_cell5 ?cur_cell6

?cur_cell7 ?cur_cell8 ?cur_cell9)

(bind ?a ?depth)

(if (= ?*hType* 1) then (bind ?a (+ ?a (h1 ?cur_cell1 ?cur_cell2 ?cur_cell3 ?cur_cell4 ?cur_cell5 ?cur_cell6 ?cur_cell7 ?cur_cell8 ?cur_cell9))))

(if (= ?*hType* 2) then (bind ?a (+ ?a (h2 ?cur_cell1 ?cur_cell2 ?cur_cell3 ?cur_cell4 ?cur_cell5 ?cur_cell6 ?cur_cell7 ?cur_cell8 ?cur_cell9))))

(return ?a)

)

(deffunction setID()

(bind ?*ID* (+ ?*ID* 1))

(return ?*ID*)

)

;; reset node

(deffacts initial

(Node (id (setID))

(cell1 ?*initial_cell1*) (cell2 ?*initial_cell2*) (cell3 ?*initial_cell3*)

(cell4 ?*initial_cell4*) (cell5 ?*initial_cell5*) (cell6 ?*initial_cell6*)

(cell7 ?*initial_cell7*) (cell8 ?*initial_cell8*) (cell9 ?*initial_cell9*)

(depth 0) (parent 0)

(f (getF 0 ?*initial_cell1* ?*initial_cell2* ?*initial_cell3* ?*initial_cell4* ?*initial_cell5* ?*initial_cell6* ?*initial_cell7* ?*initial_cell8* ?*initial_cell9*))

)

(min (getF 0 ?*initial_cell1* ?*initial_cell2* ?*initial_cell3* ?*initial_cell4* ?*initial_cell5* ?*initial_cell6* ?*initial_cell7* ?*initial_cell8* ?*initial_cell9*))

(if (= ?*DEBUG* 1)

(printout t crlf "initial state:" crlf

"ID=1 " "Depth=0 " "F=" (getF 0 ?*initial_cell1* ?*initial_cell2* ?*initial_cell3* ?*initial_cell4* ?*initial_cell5* ?*initial_cell6* ?*initial_cell7* ?*initial_cell8* ?*initial_cell9*) " Parent=0 " crlf

?*initial_cell1* " " ?*initial_cell2* " " ?*initial_cell3* crlf

?*initial_cell4* " " ?*initial_cell5* " " ?*initial_cell6* crlf

?*initial_cell7* " " ?*initial_cell8* " " ?*initial_cell9* crlf

"If you are in debug mode, enter any symbol and hit ENTER on each step to continue"

)

)

)

;; show result

(defrule result

(declare (salience 500))

?container <- (Node (id ?v_id)

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth ?v_g) (status ~2) (parent ?v_parent) (f ?v_f)

)

(test (= ?v_cell1 ?*result_cell1*))

(test (= ?v_cell2 ?*result_cell2*))

(test (= ?v_cell3 ?*result_cell3*))

(test (= ?v_cell4 ?*result_cell4*))

(test (= ?v_cell5 ?*result_cell5*))

(test (= ?v_cell6 ?*result_cell6*))

(test (= ?v_cell7 ?*result_cell7*))

(test (= ?v_cell8 ?*result_cell8*))

(test (= ?v_cell9 ?*result_cell9*))

=>

(modify ?container(status 2))

(printout t crlf "==================================================" crlf

"Path:" crlf

"ID=" ?v_id " Depth=" ?v_g " F=" ?v_f " Parent=" ?v_parent crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell5 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

)

;; no solution check

(defrule stop_if_no_solution

(declare (salience 200))

(not (Node(status 0|2)))

=>

(halt)

(printout t crlf "Solution not found." crlf)

)

(defrule stop_if_solution_found

(declare (salience 200))

(Node(status 2))

=>

(halt)

(printout t crlf "Solution found! " crlf)

(printout t "Nodes created: " ?*unique_nodes* crlf)

(printout t "Steps passed: " ?*total_steps* crlf)

)

;; no minimum found

(defrule fix_min

(declare (salience 175))

?f_addr_min <- (min ?min)

(not (exists (Node (f ?F&:(<= ?F ?min)) (status 0))))

=>

(retract ?f_addr_min)

(assert (min (+ ?min 1)))

)

;; minimum

(defrule find_min

(declare (salience 150))

?f_addr_min <- (min ?min)

(Node (f ?F&:(< ?F ?min)) (status 0))

=>

(retract ?f_addr_min)

(assert (min ?F))

)

;; remove duplicates

(defrule remove_repeats

(declare (salience 1000));

?f_addr_1 <-(Node (id ?v_id_1)

(cell1 ?v_cell1_1) (cell2 ?v_cell2_1) (cell3 ?v_cell3_1)

(cell4 ?v_cell4_1) (cell5 ?v_cell5_1) (cell6 ?v_cell6_1)

(cell7 ?v_cell7_1) (cell8 ?v_cell8_1) (cell9 ?v_cell9_1)

(depth ?v_g_1) (status 1) (parent ?v_parent_1) (f ?v_f_1)

)

?f_addr_2 <-(Node (id ?v_id_2&~?v_id_1)

(cell1 ?v_cell1_2&:(= ?v_cell1_1 ?v_cell1_2)) (cell2 ?v_cell2_2&:(= ?v_cell2_1 ?v_cell2_2)) (cell3 ?v_cell3_2&:(= ?v_cell3_1 ?v_cell3_2))

(cell4 ?v_cell4_2&:(= ?v_cell4_1 ?v_cell4_2)) (cell5 ?v_cell5_2&:(= ?v_cell5_1 ?v_cell5_2)) (cell6 ?v_cell6_2&:(= ?v_cell6_1 ?v_cell6_2))

(cell7 ?v_cell7_2&:(= ?v_cell7_1 ?v_cell7_2)) (cell8 ?v_cell8_2&:(= ?v_cell8_1 ?v_cell8_2)) (cell9 ?v_cell9_2&:(= ?v_cell9_1 ?v_cell9_2))

(depth ?v_g_2) (status 0) (parent ?v_parent_2) (f ?v_f_2)

)

=>

(if (= ?*DEBUG* 1) then

(printout t crlf "Deleting repeat node:" crlf)

(printout t "ID=" ?v_id_2 " Depth=" ?v_g_2 " F=" ?v_f_2 " Parent=" ?v_parent_2 crlf

?v_cell1_2 " " ?v_cell2_2 " " ?v_cell3_2 crlf

?v_cell4_2 " " ?v_cell5_2 " " ?v_cell6_2 crlf

?v_cell7_2 " " ?v_cell8_2 " " ?v_cell9_2 crlf

"=====" crlf

(bind ?enter (read))

)

)

(if (<= ?v_f_1 ?v_f_2) then

(retract ?f_addr_2)

(if (= ?*DEBUG* 1) then (printout t "Deleting repeat node..." crlf))

else

(modify ?f_addr_1 (parent ?v_parent_2) (depth ?v_g_2) (f ?v_f_2))

(retract ?f_addr_2)

(if (= ?*DEBUG* 1) then (printout t "Deleting and refreshing" crlf))

)

(bind ?*unique_nodes* (- ?*unique_nodes* 1))

)

;; show the way

(defrule show_answer

(declare (salience 500))

(Node (id ?v_id) (status 2) (parent ?v_pid))

?container <- (Node(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(id ?v_pid) (status ~2) (parent ?v_parent) (depth ?v_g) (f ?v_f))

=>

(modify ?container(status 2))

(printout t "ID=" ?v_pid " Depth=" ?v_g " F=" ?v_f " Parent=" ?v_parent crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell5 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

)

;; remove not correct nodes

(defrule delete_not_answer

(declare (salience 400))

(Node(status 2))

?container <- (Node(status ~2))

=>

(retract ?container);

)

;; making actions

(defrule create_cell1

(declare (salience 100))

?f_addr_min <- (min ?min)

?f_addr_node <- (Node (id ?v_id)

(cell1 0) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth ?v_g) (status 0) (parent ?v_parent)

(f ?v_f&:(= ?v_f ?min))

)

=>

(if (= ?*DEBUG* 1) then (printout t crlf "Creating 2 new nodes from node: " crlf "Id=" ?v_id " Depth=" ?v_g " F=" ?v_f " Parent=" ?v_parent crlf

(fact-slot-value ?f_addr_node cell1) " " (fact-slot-value ?f_addr_node cell2) " " (fact-slot-value ?f_addr_node cell3) crlf

(fact-slot-value ?f_addr_node cell4) " " (fact-slot-value ?f_addr_node cell5) " " (fact-slot-value ?f_addr_node cell6) crlf

(fact-slot-value ?f_addr_node cell7) " " (fact-slot-value ?f_addr_node cell8) " " (fact-slot-value ?f_addr_node cell9) crlf

"====="crlf

)

)

(modify ?f_addr_node(status 1))

(bind ?a1 (getF (+ ?v_g 1) ?v_cell2 0 ?v_cell3 ?v_cell4 ?v_cell5 ?v_cell6 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell2) (cell2 0 ) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a1)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell2 " 0 " ?v_cell3 crlf

?v_cell4 " " ?v_cell5 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a2 (getF (+ ?v_g 1) ?v_cell4 ?v_cell2 ?v_cell3 0 ?v_cell5 ?v_cell6 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell4) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 0) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a2)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell4 " " ?v_cell2 " " ?v_cell3 crlf

"0 " ?v_cell5 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?*unique_nodes* (+ ?*unique_nodes* 2))

(bind ?*total_steps* (+ ?*total_steps* 1))

)

(defrule create_cell2

(declare (salience 100))

?f_addr_min <- (min ?min)

?f_addr_node <- (Node (id ?v_id)

(cell1 ?v_cell1) (cell2 0) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth ?v_g) (status 0) (parent ?v_parent)

(f ?v_f&:(= ?v_f ?min))

)

=>

(if (= ?*DEBUG* 1) then (printout t crlf "Creating 3 new node from node: " crlf "Id=" ?v_id " Depth=" ?v_g " F=" ?v_f " Parent=" ?v_parent crlf

(fact-slot-value ?f_addr_node cell1) " " (fact-slot-value ?f_addr_node cell2) " " (fact-slot-value ?f_addr_node cell3) crlf

(fact-slot-value ?f_addr_node cell4) " " (fact-slot-value ?f_addr_node cell5) " " (fact-slot-value ?f_addr_node cell6) crlf

(fact-slot-value ?f_addr_node cell7) " " (fact-slot-value ?f_addr_node cell8) " " (fact-slot-value ?f_addr_node cell9) crlf

"====="crlf

)

(bind ?enter (read))

)

(modify ?f_addr_node(status 1))

(bind ?a1 (getF (+ ?v_g 1) 0 ?v_cell1 ?v_cell3 ?v_cell4 ?v_cell5 ?v_cell6 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 0) (cell2 ?v_cell1) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a1)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

"0 " ?v_cell1 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell5 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a2 (getF (+ ?v_g 1) ?v_cell1 ?v_cell5 ?v_cell3 ?v_cell4 0 ?v_cell6 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell5) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 0) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a2)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell5 " " ?v_cell3 crlf

?v_cell4 " 0 " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a3 (getF (+ ?v_g 1) ?v_cell1 ?v_cell3 0 ?v_cell4 ?v_cell5 ?v_cell6 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell3) (cell3 0)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a3)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell3 " 0" crlf

?v_cell4 " " ?v_cell5 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?*unique_nodes* (+ ?*unique_nodes* 3))

(bind ?*total_steps* (+ ?*total_steps* 1))

)

(defrule create_cell3

(declare (salience 100))

?f_addr_min <- (min ?min)

?f_addr_node <- (Node (id ?v_id)

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 0)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth ?v_g) (status 0) (parent ?v_parent)

(f ?v_f&:(= ?v_f ?min))

)

=>

(if (= ?*DEBUG* 1) then (printout t crlf "Creating 2 new node from node: " crlf "Id=" ?v_id " Depth=" ?v_g " F=" ?v_f " Parent=" ?v_parent crlf

(fact-slot-value ?f_addr_node cell1) " " (fact-slot-value ?f_addr_node cell2) " " (fact-slot-value ?f_addr_node cell3) crlf

(fact-slot-value ?f_addr_node cell4) " " (fact-slot-value ?f_addr_node cell5) " " (fact-slot-value ?f_addr_node cell6) crlf

(fact-slot-value ?f_addr_node cell7) " " (fact-slot-value ?f_addr_node cell8) " " (fact-slot-value ?f_addr_node cell9) crlf

"====="crlf

)

(bind ?enter (read))

)

(modify ?f_addr_node(status 1))

(bind ?a1 (getF (+ ?v_g 1) ?v_cell1 0 ?v_cell2 ?v_cell4 ?v_cell5 ?v_cell6 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 0) (cell3 ?v_cell2)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a1)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " 0 " ?v_cell2 crlf

?v_cell4 " " ?v_cell5 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a2 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell6 ?v_cell4 ?v_cell5 0 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell6)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 0)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a2)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell6 crlf

?v_cell4 " " ?v_cell5 " 0" crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?*unique_nodes* (+ ?*unique_nodes* 2))

(bind ?*total_steps* (+ ?*total_steps* 1))

)

(defrule create_cell4

(declare (salience 100))

?f_addr_min <- (min ?min)

?f_addr_node <- (Node (id ?v_id)

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 0) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth ?v_g) (status 0) (parent ?v_parent)

(f ?v_f&:(= ?v_f ?min))

)

=>

(if (= ?*DEBUG* 1) then (printout t crlf "Creating 3 new node from node: " crlf "Id=" ?v_id " Depth=" ?v_g " F=" ?v_f " Parent=" ?v_parent crlf

(fact-slot-value ?f_addr_node cell1) " " (fact-slot-value ?f_addr_node cell2) " " (fact-slot-value ?f_addr_node cell3) crlf

(fact-slot-value ?f_addr_node cell4) " " (fact-slot-value ?f_addr_node cell5) " " (fact-slot-value ?f_addr_node cell6) crlf

(fact-slot-value ?f_addr_node cell7) " " (fact-slot-value ?f_addr_node cell8) " " (fact-slot-value ?f_addr_node cell9) crlf

"====="crlf

)

(bind ?enter (read))

)

(modify ?f_addr_node(status 1))

(bind ?a1 (getF (+ ?v_g 1) 0 ?v_cell2 ?v_cell3 ?v_cell1 ?v_cell5 ?v_cell6 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 0) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell1) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a1)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

"0 " ?v_cell2 " " ?v_cell3 crlf

?v_cell1 " " ?v_cell5 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a2 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell5 0 ?v_cell6 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell5) (cell5 0) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a2)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell5 " 0 " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a3 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell7 ?v_cell5 ?v_cell6 0 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell7) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 0) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a3)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell7 " " ?v_cell5 " " ?v_cell6 crlf

"0 " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?*unique_nodes* (+ ?*unique_nodes* 3))

(bind ?*total_steps* (+ ?*total_steps* 1))

)

(defrule create_cell5

(declare (salience 100))

?f_addr_min <- (min ?min)

?f_addr_node <- (Node (id ?v_id)

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 0) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth ?v_g) (status 0) (parent ?v_parent)

(f ?v_f&:(= ?v_f ?min))

)

=>

(if (= ?*DEBUG* 1) then (printout t crlf "Creating 4 new node from node: " crlf "Id=" ?v_id " Depth=" ?v_g " f=" ?v_f " Parent=" ?v_parent crlf

(fact-slot-value ?f_addr_node cell1) " " (fact-slot-value ?f_addr_node cell2) " " (fact-slot-value ?f_addr_node cell3) crlf

(fact-slot-value ?f_addr_node cell4) " " (fact-slot-value ?f_addr_node cell5) " " (fact-slot-value ?f_addr_node cell6) crlf

(fact-slot-value ?f_addr_node cell7) " " (fact-slot-value ?f_addr_node cell8) " " (fact-slot-value ?f_addr_node cell9) crlf

"====="crlf

)

(bind ?enter (read))

)

(modify ?f_addr_node(status 1))

(bind ?a1 (getF (+ ?v_g 1) ?v_cell1 0 ?v_cell3 ?v_cell4 ?v_cell2 ?v_cell6 ?v_cell7 ?v_cell8 ?v_cell9))

(retract ?f_addr_min)

(assert (min ?a1))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 0) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell2) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a1)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " 0 " ?v_cell3 crlf

?v_cell4 " " ?v_cell2 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a2 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 0 ?v_cell4 ?v_cell6 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 0) (cell5 ?v_cell4) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a2)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

"0 " ?v_cell4 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a3 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell4 ?v_cell6 0 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell6) (cell6 0)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a3)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell6 " 0" crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a4 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell4 ?v_cell8 ?v_cell6 ?v_cell7 0 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell8) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 0) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a4)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell8 " " ?v_cell6 crlf

?v_cell7 " 0 " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?*unique_nodes* (+ ?*unique_nodes* 4))

(bind ?*total_steps* (+ ?*total_steps* 1))

)

(defrule create_cell6

(declare (salience 100))

?f_addr_min <- (min ?min)

?f_addr_node <- (Node (id ?v_id)

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 0)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth ?v_g) (status 0) (parent ?v_parent)

(f ?v_f&:(= ?v_f ?min))

)

=>

(if (= ?*DEBUG* 1) then (printout t crlf "Creating 3 new node from node: " crlf "Id=" ?v_id " Depth=" ?v_g " f=" ?v_f " Parent=" ?v_parent crlf

(fact-slot-value ?f_addr_node cell1) " " (fact-slot-value ?f_addr_node cell2) " " (fact-slot-value ?f_addr_node cell3) crlf

(fact-slot-value ?f_addr_node cell4) " " (fact-slot-value ?f_addr_node cell5) " " (fact-slot-value ?f_addr_node cell6) crlf

(fact-slot-value ?f_addr_node cell7) " " (fact-slot-value ?f_addr_node cell8) " " (fact-slot-value ?f_addr_node cell9) crlf

"====="crlf

)

(bind ?enter (read))

)

(modify ?f_addr_node(status 1))

(bind ?a1 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 0 ?v_cell4 ?v_cell5 ?v_cell3 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 0)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell3)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a1)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " 0" crlf

?v_cell4 " " ?v_cell5 " " ?v_cell3 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a2 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell4 0 ?v_cell5 ?v_cell7 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 0) (cell6 ?v_cell5)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a2)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " 0 " ?v_cell5 crlf

?v_cell7 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a3 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell4 ?v_cell5 ?v_cell9 ?v_cell7 ?v_cell8 0))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell9)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 0)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a3)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell5 " " ?v_cell9 crlf

?v_cell7 " " ?v_cell8 " 0" crlf

)

(bind ?enter (read))

)

(bind ?*unique_nodes* (+ ?*unique_nodes* 3))

(bind ?*total_steps* (+ ?*total_steps* 1))

)

(defrule create_cell7

(declare (salience 100))

?f_addr_min <- (min ?min)

?f_addr_node <- (Node (id ?v_id)

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 0) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth ?v_g) (status 0) (parent ?v_parent)

(f ?v_f&:(= ?v_f ?min))

)

=>

(if (= ?*DEBUG* 1) then (printout t crlf "Creating 2 new node from node: " crlf "Id=" ?v_id " Depth=" ?v_g " F=" ?v_f " Parent=" ?v_parent crlf

(fact-slot-value ?f_addr_node cell1) " " (fact-slot-value ?f_addr_node cell2) " " (fact-slot-value ?f_addr_node cell3) crlf

(fact-slot-value ?f_addr_node cell4) " " (fact-slot-value ?f_addr_node cell5) " " (fact-slot-value ?f_addr_node cell6) crlf

(fact-slot-value ?f_addr_node cell7) " " (fact-slot-value ?f_addr_node cell8) " " (fact-slot-value ?f_addr_node cell9) crlf

"====="crlf

)

(bind ?enter (read))

)

(modify ?f_addr_node(status 1))

(bind ?a1 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 0 ?v_cell5 ?v_cell6 ?v_cell4 ?v_cell8 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 0) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell4) (cell8 ?v_cell8) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a1)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

"0 " ?v_cell5 " " ?v_cell6 crlf

?v_cell4 " " ?v_cell8 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a2 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell4 ?v_cell5 ?v_cell6 ?v_cell8 0 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell8) (cell8 0) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a2)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell5 " " ?v_cell6 crlf

?v_cell8 " 0 " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?*unique_nodes* (+ ?*unique_nodes* 2))

(bind ?*total_steps* (+ ?*total_steps* 1))

)

(defrule create_cell8

(declare (salience 100))

?f_addr_min <- (min ?min)

?f_addr_node <- (Node (id ?v_id)

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 0) (cell9 ?v_cell9)

(depth ?v_g) (status 0) (parent ?v_parent)

(f ?v_f&:(= ?v_f ?min))

)

=>

(if (= ?*DEBUG* 1) then (printout t crlf "Creating 3 new node from node: " crlf "Id=" ?v_id " Depth=" ?v_g " F=" ?v_f " Parent=" ?v_parent crlf

(fact-slot-value ?f_addr_node cell1) " " (fact-slot-value ?f_addr_node cell2) " " (fact-slot-value ?f_addr_node cell3) crlf

(fact-slot-value ?f_addr_node cell4) " " (fact-slot-value ?f_addr_node cell5) " " (fact-slot-value ?f_addr_node cell6) crlf

(fact-slot-value ?f_addr_node cell7) " " (fact-slot-value ?f_addr_node cell8) " " (fact-slot-value ?f_addr_node cell9) crlf

"====="crlf

)

(bind ?enter (read))

)

(modify ?f_addr_node(status 1))

(bind ?a1 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell4 0 ?v_cell6 ?v_cell7 ?v_cell5 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 0) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell5) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a1)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " 0 " ?v_cell6 crlf

?v_cell7 " " ?v_cell5 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a2 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell4 ?v_cell5 ?v_cell6 0 ?v_cell7 ?v_cell9))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 0) (cell8 ?v_cell7) (cell9 ?v_cell9)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a2)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell5 " " ?v_cell6 crlf

"0 " ?v_cell7 " " ?v_cell9 crlf

)

(bind ?enter (read))

)

(bind ?a3 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell4 ?v_cell5 ?v_cell6 ?v_cell7 ?v_cell9 0))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell9) (cell9 0)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a3)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell5 " " ?v_cell6 crlf

?v_cell7 " " ?v_cell9 " 0" crlf

)

(bind ?enter (read))

)

(bind ?*unique_nodes* (+ ?*unique_nodes* 3))

(bind ?*total_steps* (+ ?*total_steps* 1))

)

(defrule create_cell9

(declare (salience 100))

?f_addr_min <- (min ?min)

?f_addr_node <- (Node (id ?v_id)

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 0)

(depth ?v_g) (status 0) (parent ?v_parent)

(f ?v_f&:(= ?v_f ?min))

)

=>

(if (= ?*DEBUG* 1) then (printout t crlf "Creating 2 new node from node: " crlf "Id=" ?v_id " Depth=" ?v_g " F=" ?v_f " Parent=" ?v_parent crlf

(fact-slot-value ?f_addr_node cell1) " " (fact-slot-value ?f_addr_node cell2) " " (fact-slot-value ?f_addr_node cell3) crlf

(fact-slot-value ?f_addr_node cell4) " " (fact-slot-value ?f_addr_node cell5) " " (fact-slot-value ?f_addr_node cell6) crlf

(fact-slot-value ?f_addr_node cell7) " " (fact-slot-value ?f_addr_node cell8) " " (fact-slot-value ?f_addr_node cell9) crlf

"====="crlf

)

(bind ?enter (read))

)

(modify ?f_addr_node(status 1))

(bind ?a1 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell4 ?v_cell5 0 ?v_cell7 ?v_cell8 ?v_cell6))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 0)

(cell7 ?v_cell7) (cell8 ?v_cell8) (cell9 ?v_cell6)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a1)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell5 " 0" crlf

?v_cell7 " " ?v_cell8 " " ?v_cell6 crlf

)

(bind ?enter (read))

)

(bind ?a2 (getF (+ ?v_g 1) ?v_cell1 ?v_cell2 ?v_cell3 ?v_cell4 ?v_cell5 ?v_cell6 ?v_cell7 0 ?v_cell8))

(assert (Node (id (setID))

(cell1 ?v_cell1) (cell2 ?v_cell2) (cell3 ?v_cell3)

(cell4 ?v_cell4) (cell5 ?v_cell5) (cell6 ?v_cell6)

(cell7 ?v_cell7) (cell8 0) (cell9 ?v_cell8)

(depth (+ ?v_g 1)) (status 0) (parent ?v_id) (f ?a2)

)

)

(if (= ?*DEBUG* 1) then (printout t "To uncover:" crlf

?v_cell1 " " ?v_cell2 " " ?v_cell3 crlf

?v_cell4 " " ?v_cell5 " " ?v_cell6 crlf

?v_cell7 " 0 " ?v_cell8 crlf

)

(bind ?enter (read))

)

(bind ?*unique_nodes* (+ ?*unique_nodes* 2))

(bind ?*total_steps* (+ ?*total_steps* 1))

)

Соседние файлы в предмете Введение в искусственный интеллект