【发布时间】:2011-09-12 13:20:01
【问题描述】:
我有以下问题:有一些塔是在桌子上用立方体建造的。
a
b d
c e
------------------- <- table
现在我想将立方体移动到另一种情况,比如这个:
c e
a b d
-------------------
Prolog 程序应该打印到达这种情况的步骤,例如:move cube a onto the table,等等。我有 Prolog 中表示的第一种情况:
clean(t). % t is the table, you can always put things there
clean(X) :- \+ on(_,X). % X is the top element, if there is nothing above it
on(a,b). % a is on b
on(b,c). % b on c
on(d,e). % d on e
on(c,t). % c on the table
on(e,t). % and e on the table
现在我的问题是找到一个解决方案,让 Prolog 打印新情况的步骤。我的第一个问题是,如何告诉 Prolog 新情况如何。我尝试了一些列表,但直到现在我才成功。
有人知道如何解决这个问题吗?
【问题讨论】:
-
我认为您可能需要说明其他事实,例如 nextTo(a, b)?
-
nextTo 是什么意思?左还是右?还是以上?
-
我是说如果你没有额外的事实,你可能无法让 prolog 打印你的新情况。我的意思是左和右,但如果这对您来说不明确,请尝试使用另一个标识符名称。
-
嗯好的,但是如何打印要移动的立方体的步骤?
标签: prolog