Marilena Lazari
Marilena Lazari

Reputation: 13

No implemantation in prolog MAZE

enter image description here

Maze from a to e.

When I run get(a,e[a]).

2

Upvotes: 1

Views: 101

Answers (1)

slago
slago

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

Related Questions