这就是我的.pro文件内容(AMZI PROLOG):
room(kitchen).
room(office).
room(hall).
room('dining room').
room(cellar).
door(office, hall).
door(kitchen, office).
door(hall, 'dining room').
door(kitchen, cellar).
door('dining room', kitchen).
location(desk,office).
location(apple,kitchen).
location(flashlight,desk).
location('washing machine',cellar).
location(nani,'washing machine').
location(broccoli,kitchen).
location(crackers,kitchen).
location(computer,office).
location(envelope,desk).
location(stamp,envelope).
location(key,envelope).
edible(apple).
edible(crackers).
tastes_yucky(broccoli).
here(kitchen).
is_located_in(T1,T2):-location(X,T2),is_located_in(T1,X).我想实现的是,例如,如果我使用is_located_in(X,office),那么结果将是:
X=desk,
X=flashlight,
X=computer,
X=envelope,
X=stamp,
X=key,
no(没有特定的顺序)。
这样,结果将包括基本上位于办公室中对象内/上的东西,而不是直接位于办公室中的东西。
这是来源:http://www.amzi.com/AdventureInProlog/a8recurs.php
声明代码是正常的,但当我测试它时,它只是返回:
no请帮帮忙。谢谢。
发布于 2012-12-14 21:41:12
尝试以下操作(按此顺序):
is_located_in(T1,T2):-location(T1,T2).
is_located_in(T1,T2):-location(X,T2),is_located_in(T1,X).https://stackoverflow.com/questions/13879670
复制相似问题