我正在用prolog开发一个基于文本的冒险游戏。我试图定义一些东西,打印出所有相邻的房间和他们的描述,除了当我尝试使用它时,它是打印重复的项目和他们的描述。
adjacent_rooms(Location):-
is_connected(Location, AdjacentLocation),
name(AdjacentLocation, AdjacentName),
short_desc(AdjacentLocation, AdjacentDescription),
write(AdjacentName), write(': '), write(AdjacentDescription),nl,fail.
adjacent_rooms(_).
下面是当我调用相邻的房间(卧室)时的输出。
?- 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
是什么原因导致打印重复的名称和描述?谢谢。