请帮帮忙。我在GNU prolog中遇到这个编译错误,当我使用SWISH时,它看起来像代码编译,但当我尝试?- current_room(X)时。不管怎样,它显示了我的错误(只是false),所以我认为我定义动态的方式有些不正确。
% Rooms
:- dynamic current_room/1.
room(kitchen).
room(hall).
room(living_room).
room(dinning).
path(kitchen,dinning,n).
path(kitchen,hall2,e).
path(hall,living_room,s).
path(living_room,hall,n).
path(living_room,hall2,s).
path(living_room,dinning,w).
path(dinning,living_room,e).
path(dinning,kitchen,s).
path(hall2,living_room,n).
path(hall2,pantry,s).
path(pantry,hall2,n).
objects(couch).
in_room(living_room,couch).
route(room).
%(current_room,Destination, X).
%asserta(current_room(Destination)).
move(X) :- current_room(Z), path(Z,Y,X), retractall(my_pos(Z)), assert(my_pos(Y)).
n :- move(n).
s :- move(s).
w :- move(w).
e :- move(e).
start :- write('Type n/s/e/w'),nl, asserta(current_room(hall2)).发布于 2021-01-23 23:06:56
GNU prolog具有不同的语法:- dynamic(current_room/1).。
https://stackoverflow.com/questions/65860665
复制相似问题