我遇到以下问题:桌子上有一些用立方体建造的塔。在Prolog中将立方体从位置A移动到位置
a
b d
c e
------------------- <- table
现在我想立方体移动到另一种情况,像这样的:
c e
a b d
-------------------
的Prolog程序应该打印步骤获得这种情况,例如:move cube a onto the table
,等等。我在序言代表的第一种情况:
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是什么意思?左还是右?或以上? – Tobias
我在说如果你没有额外的事实,你可能无法做出prolog打印你的新情况。我的意思是左和右,但如果这对你来说模棱两可,请尝试使用另一个标识符名称。 –