我正在Prolog中开发一款基于文本的冒险游戏。我正在尝试定义一种可以打印出所有相邻房间及其描述的内容,但是当我尝试使用它时,它会打印出重复的项目及其描述。
neighboring_rooms的定义如下:
adjacent_rooms(Location):-
is_connected(Location, AdjacentLocation),
name(AdjacentLocation, AdjacentName),
short_desc(AdjacentLocation, AdjacentDescription),
write(AdjacentName), write(': '), write(AdjacentDescription),nl,fail.
adjacent_rooms(_).
下面是当我调用neighbor_rooms(bedroom)的输出。
?- adjacent_rooms(bedroom).
Your Bedroom's Closet: A cozy little room used for storing your valuables
Your Bedroom's Closet:
: A cozy little room used for storing your valuables
:
Hallway: Long pathway that has pictures hanging on wall
Hallway:
: Long pathway that has pictures hanging on wall
是什么导致打印重复的名称和描述?谢谢。