CLIPS阻止世界第2部分

时间:2018-10-09 00:32:53

标签: clips

这里有人帮助我修复了代码,它非常适合:

(断言(A B C堆)(D E F堆)(目标D C B堆)(目标A堆)(目标F堆))

(断言(A B C D E F筹码(目标A B C D E F筹码))

但是:

(断言(A B C栈)(目标A B B(目标C栈))

它只是将A放在地板上然后停下来。

这是我的新代码:

(defrule move-direct
 ?stack1 <- (stack ?block1 $?bottom)
 ?stack2 <- (stack ?block2 $?goalbottom)
 (goal-stack $? ?block1 ?block2 $?goalbottom)
 =>
 (retract ?stack1 ?stack2)
 (assert (stack ?block1 ?block2 ?goalbottom))
 (assert (stack $?bottom))
 (printout t ?block1 " moved on top of " ?block2 crlf))




(defrule move-on-floor
 ?stack <- (stack ?top $?middle ?next $?bottom)
 (goal-stack $? ?next $?goalbottom)
 (not (stack $? ?next $?goalbottom))
 =>
 (retract ?stack)
 (assert (stack ?top))
 (assert (stack $?middle ?next $?bottom))
 (printout t ?top " moved on to the floor" crlf))

0 个答案:

没有答案