Reputation: 13
Maze from a to e.
When I run get(a,e[a]).
Upvotes: 1
Views: 101
Reputation: 5509
As I said in the previous comment, the problem is that get/3
is a predicate predefined in library(pce)
. Fixing your code is simple:
door(a,b).
door(b,c).
door(c,d).
door(d,e).
myget(X,X,A,P) :-
reverse(A,P),
!.
myget(X,Y,A,P) :-
once(door(X,Z);door(Z,X)),
not(member(Z,A)),
format('I am in room ~w.~n', Z),
myget(Z,Y,[Z|A],P).
Query:
?- myget(a,e,[a],P).
I am in room b.
I am in room c.
I am in room d.
I am in room e.
P = [a, b, c, d, e].
Upvotes: 2