Tower of Hanoiを解決するモデルの概要を以下に示します。
Rule 1
Rule 2
Rule 3
Rule 4
関数*hanoi-otherpegは,(*hanoi-otherpeg ?x ?y)で,?x,?y以外のペグを返す関数。例えば,(*hanoi-otherpeg B C)はAを返す。
Rule 5
ルール5aからルール5cの3つのルールによって,DONE,CAN,CANNOTを判別する。具体的には,(State DONE), (State CAN), (State CANNOT 特定されたブロッキングディスク)をワーキングメモリに書き込む。
関数*hanoi-findblockingdiskは,(*hanoi-findblockingdisk ?x ?y ?z)で,ディスク?xより小さく,ディスクリスト?y,?zの中のディスクの中で最大のディスクを返す関数。例えば,(*hanoi-findblockingdisk 6 (1 3 99) (4 99))に対して,4を返す。
Rule 6
Rule 7
関数*hanoi-biggestは,(*hanoi-biggest ?x ?y)で,ディスクリスト?x,?yの中にある最大のディスクを返す関数。例えば,5枚ディスク問題で,(*hanoi-biggest (1 3 99)(5 99))に対して,5を返す。
- (1 C) - (2 B) - (3 C) - (4 C) - (5 B) - (6 C) - (A (99)) - (B (2 5 99)) - (C (1 3 4 6 99))■ワーキングメモリ:テスト課題2
- (1 A) - (2 B) - (3 B) - (4 A) - (5 C) - (6 B) - (A (1 4 99)) - (B (2 3 6 99)) - (C (5 99))
- name: rule1 if: - (B ?listb) - (A ?lista) - (*test-equal (TEMP1) TEMP2) - (*test-equal (TEMP3) TEMP4) then: - (*deposit (Problem-Solved)) - (*halt) - name: rule2 if: - (State DONE) - (Goal (DMove ?disk ?peg)) then: - (*delete (State TEMP5)) - (*delete (Goal (DMove ?disk ?peg))) - (*deposit (Goal (DMove (*minus TEMP6 TEMP7) TEMP8))) - name: rule3 if: - (Goal (DMove ?disk ?peg-a)) - (State CAN) - (?disk ?peg-b) - (?peg-a ?lista) - (?peg-b ?listb) then: - (*delete (State CAN)) - (*delete (Goal (DMove ?disk ?peg-a))) - (*delete (?disk TEMP9)) - (*deposit (?disk TEMP10)) - (*delete (TEMP11 ?listb)) - (*deposit (TEMP12 (*remove TEMP13 TEMP14))) - (*delete (?peg-a ?lista)) - (*deposit (?peg-a (*cons TEMP15 TEMP16))) - name: rule4 if: - (Goal (DMove ?disk ?peg-a)) - (State CANT ?blockingdisk) - (?disk ?peg-b) then: - (*delete (State CANT ?blockingdisk)) - (*deposit (Goal (DMove TEMP17 (*hanoi-otherpeg TEMP18 TEMP19)))) - name: rule5a(test->done) if: - (Goal (DMove ?disk ?peg-a)) - (TEMP20 TEMP21) then: - (*deposit (State DONE)) - name: rule5b(test->can) if: - (Goal (DMove ?disk ?peg-a)) - (?disk ?peg-b) - (?peg-b ?listb) - (?peg-a ?lista) - (*test-equal ?disk (*first TEMP22)) - (*test-smaller ?disk (*first TEMP23)) then: - (*deposit (State CAN)) - name: rule5c(test->cant) if: - (Goal (DMove ?disk ?peg-a)) - (?disk ?peg-b) - (?peg-a ?lista) - (?peg-b ?listb) then: - (*deposit (State CANT (*hanoi-findblockingdisk TEMP24 TEMP25 TEMP26))) - name: rule6 if: - (Biggest ?disk) then: - (*delete (Biggest ?disk)) - (*deposit (Goal (DMove TEMP27 C))) - name: rule7 if: - (A ?lista) - (B ?listb) then: - (*deposit (Biggest (*hanoi-biggest TEMP28 TEMP29)))